Demo application for a Spring Boot service which exposes a gRPC endpoint. Built using Maven.
Make sure you have Java 17+ installed.
Compile and run unit tests:
./mvnw clean verify
Run integration tests:
./mvnw clean verify -Dskip.unitTests=true -Pfunctional-tests
You can run the app (i.e. com.nkatirtzis.grpcdemo.Application) on Intellij.
./mvnw spring-boot:run
To run the jar file:
java -jar service/target/service-0.0.1-SNAPSHOT-exec.jar
To run the application as a Docker container in a minikube cluster:
make minikube-build
minikube kubectl -- apply -f charts/install.yaml
Property | Default value | Description |
---|---|---|
grpc.port |
6565 | Port where gRPC server is running |
spring.zipkin.enabled |
true | Enables Zipkin for traces |
spring.zipkin.baseUrl |
http://127.0.0.1:9411/ | Host where trace data will be sent to. Need to be set if spring.zipkin.enabled is set to true. |
spring.sleuth.sampler.probability |
1 | Configures the probability of spans exported. Value should be in range [0.0,1.0] |
This app comes with server reflection enabled.
You can use a gRPC cmd tool such as grpc_cli or grpcurl to send requests to the app.
Check the server’s health status using grpc_cli:
grpc_cli call localhost:6565 Check ''
or using grpcurl:
grpcurl -plaintext -d '' localhost:6565 grpc.health.v1.Health/Check
Hit the main endpoint using grpc_cli:
grpc_cli call localhost:6565 Reviews 'id:1'
or using grpcurl:
grpcurl -plaintext -d '{"id": 1}' localhost:6565 ReviewsService/GetReviews
The app exposes an endpoint under /metrics
where you can see a list of available metrics.
It has also been instrumented to report traces to Zipkin. To run Zipkin locally:
docker run -p 9411:9411 openzipkin/zipkin
Once you make gRPC request(s) to the app traces will be available on http://localhost:9411/zipkin/
.