https://github.com/phxql/spring-boot-grpc-showcase
This small project showcases Spring together with gRPC
https://github.com/phxql/spring-boot-grpc-showcase
Last synced: 2 days ago
JSON representation
This small project showcases Spring together with gRPC
- Host: GitHub
- URL: https://github.com/phxql/spring-boot-grpc-showcase
- Owner: phxql
- License: unlicense
- Created: 2020-06-29T12:53:21.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-29T12:55:15.000Z (about 6 years ago)
- Last Synced: 2025-01-08T08:14:26.501Z (over 1 year ago)
- Language: Java
- Size: 62.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spring Boot with gRPC
This small project showcases Spring together with gRPC. It consists of 3 modules:
* `protocol`: contains the proto file and the rpc definition. Will generate java classes when compiled.
* `server`: uses protocol module, implemements the rpc stub in Spring Boot
* `client`: uses protocol module, implements a client in plain java (no Spring)
The project uses [grpc-spring-boot-starter](https://github.com/LogNet/grpc-spring-boot-starter) for the heavy
lifting.
The main work on that was to get the Gradle build files right.
## Build it
`./gradlew clean build`
## Run it via gradle
1. `./gradlew :server:bootRun`
1. `./gradlew :client:run` in another terminal
## Invoke the service via grpc-cli
The server has gRPC reflection support enabled (see [application.yaml](server/src/main/resources/application.yaml)),
so you can invoke the service via the grpc-cli. First start the server, then interact with it via the CLI:
```
# Start server
./gradlew :server:bootRun
# List all services
grpc_cli ls localhost:6565
# Get HelloWorldService definition
grpc_cli ls localhost:6565 -l grpcchat.HelloWorld
# Get request proto definition
grpc_cli type localhost:6565 grpcchat.HelloWorldRequest
# Get response proto definition
grpc_cli type localhost:6565 grpcchat.HelloWorldResponse
# Call the service
grpc_cli call localhost:6565 grpcchat.HelloWorld.Hello "name: 'Moritz'"
```
# License
Licensed under [Unlicense](https://unlicense.org/).