natemurthy / grpc-java-sbt

Runs Java's gRPC hello-world example using SBT build, instead of Gradle or Maven

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

Requirements

  • grpc-java plugin 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;
  • protobuf compiler available (version 3.0.0 or up). You can find more information at google/protobuf;
  • sbt to 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_PROTOC with the path for your protoc bin;
  • PATH_GRPC_JAVA_PLUGIN with the path for the protoc-gen-grpc-java gRPC 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

About

Runs Java's gRPC hello-world example using SBT build, instead of Gradle or Maven


Languages

Language:Java 55.2%Language:Go 17.2%Language:Protocol Buffer 15.6%Language:Scala 12.0%