akoua / grpc-demo

gRPC with Spring Boot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gRPC demo with Spring Boot

gRPC with Spring Boot

Client Testing

Now I use evans for gRPC client test, please refer https://github.com/ktr0731/evans for test. the demo is in 'src/main/proto'

Load Balance

    ManagedChannel channel = ManagedChannelBuilder
            .forTarget("eureka://grpc-service-1")
            .nameResolverFactory(new EurekaNameResolverProvider(eurekaClientConfig))
            .loadBalancerFactory(RoundRobinLoadBalancerFactory.getInstance())
            .usePlaintext(true)
            .build();

  • target: the compliant URI for NameResolver. URL can contains gRPC service name
class XdsNameResolverProvider extends NameResolverProvider {
     
     public XdsNameResolver newNameResolver(URI targetUri, Args args) { 
     
     }
 }

Health check

Please refer grpc-services-1.13.1.jar!/grpc/health/v1/health.proto and io.grpc.health.v1.HealthGrpc, and almost you should implement HealthGrpc.HealthImplBase for health checking, please check HealthServiceImpl.java

$ cd src/main/health-check
$ evans

TLS

Please consider to use mkcert for testing

 grpc:
    security:
      cert-chain: classpath:cert/server-cert.pem
      private-key: file:../grpc-spring-boot-starter-demo/src/test/resources/cert/server-key.pem

Reactive gPRC

Reactive programming with grpc-java: https://github.com/salesforce/reactive-grpc

References

Java without IDL

About

gRPC with Spring Boot


Languages

Language:Java 100.0%