natemurthy/grpc-java-sbt
Runs Java's gRPC hello-world example using SBT build, instead of Gradle or Maven
grpc-java-sbt
Runs a basic gRPC hello-world Java example ported from Google's repository using SBT build tool, instead of Gradle or Maven (the ones Google's official repository gives support), leveraged on sbt-protobuf plugin.
More infomation
Please refer to the following links for more information:
- gRPC protocol at www.grpc.io and its java tutorial];
- gRPC Java's and its plugin at grpc/grpc-java`;
- Google's Protocol Buffers at google/protobuf;
- SBT
protobufplugin at sbt-protobuf.
Requirements
grpc-javaplugin built. I recommend you to build it from source (downloading from Maven Central is also a possibility if compatible with your OS). You can find build instructions at the grpc-java;protobufcompiler available (version3.0.0or up). You can find more information at google/protobuf;sbtto build the project
Check the repo's Dockerfile for some hints on how to setup your system. More info on the Docker image below.
Settings
Update build.sbt replacing the following values:
PATH_PROTOCwith the path for yourprotocbin;PATH_GRPC_JAVA_PLUGINwith the path for theprotoc-gen-grpc-javagRPC Java's protobuf plugin.
Run
In one terminal run sbt run and select the hello-world-server main to spawn a server. In another terminal run sbt run again and select hello-world-client main to spawn a client (you can spawn multiple clients by repeating this step).
That's it!
Docker
I'm also providing a Dockerfile that builds an image that pre-builds all the listed requirements, and runs the example.
- To build the image just run:
docker build --rm -t jfloff/grpc-java-sbt . - Run the image with:
docker run -it --name grpc-java-sbt jfloff/grpc-java-sbt - And for a 2nd terminal run:
docker exec -ti grpc-java-sbt run sbt