-
-
Notifications
You must be signed in to change notification settings - Fork 1
Basic Buf Example #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Luka-J9
wants to merge
10
commits into
scalapb:main
Choose a base branch
from
Luka-J9:basic-example
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2457d92
basic example with some very basic docs
ab9857d
draw the owl
a701733
update some of the readme
0c4af6d
update readme
699b324
add types
6746c06
cleanup readme some more, left around different drafts and added a co…
cbaa4ef
update with local plugin example
efec217
update readme and ignore files
Luka-J9 e5ab2c1
minor edits
Luka-J9 a2c42e2
Merge pull request #1 from Luka-J9/basic-example-with-advanced-buffing
Luka-J9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
*.class | ||
*.log | ||
.vscode | ||
.metals | ||
.history | ||
.bloop | ||
metals.sbt | ||
target/ | ||
.bsp | ||
|
||
#Probably not the best idea but to keep this repo clean and let people run stuff themselves | ||
/src/main/scala/com/example/petstore/generated |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
An example. I believe these text is not correct.# Scala Pb Buf Examples. | ||
|
||
More documentation to come... | ||
|
||
## What is Buf | ||
Great tool for protobuf dependency management - a better explanation to come | ||
|
||
## Prerequisites | ||
|
||
This guide assumes you have Scala/SBT. | ||
|
||
## Getting Started | ||
|
||
Follow the instructions of the [Buf install guide](https://buf.build/docs/installation) | ||
|
||
Run the following command to see your code get generated: | ||
“` | ||
buf generate | ||
“` | ||
|
||
|
||
## My Scala Plugin doesn't exist; what do? | ||
|
||
Plugins that are live: | ||
|
||
[Base Scala Pb Compiler](https://buf.build/community/scalapb-scala) | ||
[ZIO GRPC](https://buf.build/community/scalapb-zio-grpc) | ||
|
||
The following are buf plugins that can be easily added, but require demand so the Buf team will support them. If you want to see them, PLEASE leave a thumbs up. If your company would use that plugin heavily drop a comment! | ||
[FS2 GRPC](https://github.com/bufbuild/plugins/issues/305) | ||
[Akka GRPC pre/post license change](https://github.com/bufbuild/plugins/issues/306) | ||
|
||
[Scalapb Validate](https://github.com/bufbuild/plugins/issues/304) plugin would require some help from the Buf team as their plugin test bench doesn't (at the time of writing) support chained plugins. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: v1 | ||
plugins: | ||
- plugin: buf.build/community/scalapb-scala:v0.11.13 | ||
out: src/main/scala | ||
opt: | ||
- flat_package | ||
Luka-J9 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
- grpc | ||
- plugin: buf.build/community/scalapb-zio-grpc:v0.5.3 | ||
out: src/main/scala | ||
opt: | ||
- flat_package |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
version: v1 | ||
directories: | ||
- src/main/protobuf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: v1 | ||
breaking: | ||
use: | ||
- FILE | ||
lint: | ||
use: | ||
- DEFAULT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
scalaVersion := "2.13.8" | ||
|
||
name := "scalapb-buf-examples" | ||
organization := "scalapb" | ||
version := "1.0" | ||
|
||
libraryDependencies ++= | ||
Seq( | ||
"com.thesamet.scalapb" %% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion, | ||
"com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapb.compiler.Version.scalapbVersion, | ||
"com.thesamet.scalapb.zio-grpc" %% "zio-grpc-core" % "0.5.3" | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sbt.version=1.8.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.0") | ||
libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.11.11" |
Luka-J9 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: v1 | ||
breaking: | ||
use: | ||
- FILE | ||
lint: | ||
use: | ||
- DEFAULT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
syntax = "proto3"; | ||
package petstore; | ||
|
||
option java_package = "com.example.petstore.generated"; | ||
|
||
message Pet { | ||
int32 id = 1; | ||
string name = 2; | ||
} | ||
|
||
message User { | ||
int32 id = 1; | ||
string username = 2; | ||
string email = 3; | ||
string phone = 4; | ||
} | ||
|
||
message PetByIdRequest { | ||
int32 id = 1; | ||
} | ||
|
||
message UserByNameRequest { | ||
string username = 1; | ||
} | ||
|
||
message PetResponse { | ||
Pet pet = 1; | ||
} | ||
|
||
message UserResponse { | ||
User user = 1; | ||
} | ||
|
||
message EmptyReq{ | ||
string msg = 1; | ||
} | ||
message EmptyRes{ | ||
string msg = 1; | ||
} | ||
|
||
service PetStoreService { | ||
rpc PetById (PetByIdRequest) returns (PetResponse); | ||
rpc UserByName (UserByNameRequest) returns (UserResponse); | ||
rpc ListUsers (EmptyReq) returns (stream User); | ||
rpc StoreUsers (stream User)returns (EmptyRes); | ||
rpc BulkUsers (stream User) returns (stream User); | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/scala/com/example/petstore/impl/ZioPetstoreImpl.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.example.petstore.impl | ||
|
||
class ZioPetstoreImpl { | ||
//TODO: Draw the owl | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.