Skip to content

anjeyy/grpc-sample

Repository files navigation

Sample project for a gRPC (& ReST) web service

A simple project to showcase a gRPC webservice in combination with Spring Boot. For detailed information what gRPC is, see the block quote.

Project contains three submodules, server and the corresponding client to consume the webservice. Definied .proto files have their own module, since either server and client then have the same reference compiling .proto files.

please have a look at gRPC for further information

Modules

Following listing of submodules are beeing used in this project.

Proto

Mainly used to specifiy .proto files, which are beeing used by either servers or clients. Instead of modifying every single .proto file now you can simply modifiy this one in the submodule, and the change is beeing made in all referenced maven projects.

Generating .proto files is os (operating system) independant.

Server

Server side implementation was done with grpc-spring-boot-starter. Alternatively there exists another grpc-spring-boot-starter, but the first one mentioned has more to offer out of the box.

Hint: There is no official grpc-spring-boot-starter supported by the spring-boot team.

Client

As already mentioned in section server, client side implementation was done similarily.

gRPC misc

  • On my way to exploring, understanding and implement a gRPC service I encountered a very nice tool, similar to postman.

    BloomRPC

  • A very nice introduction to gRPC with spring in Java and hands-on tutorial, I'll recommend grpc-java-example

  • For a first insight how to throw and handle errors with gRPC, this resource is helpful


kubernetes (& gRPC)

For a detailed setup with gRPC and kubernetes, have a look at gRPC kubernetes setup. If you have a running kubernetes cluster, with some finetuning the current deployment (under root directory) works for the server- & clientside.

  • server

    • exposed with loadbalancer (directly callable)
  • client

    • exposed with loadbalancer
    • calls server via dynamic grpclb (see link above)