sl-express/sentinel/sentinel-adapter/sentinel-grpc-adapter
shuhongfan cf5ac25c14 init 2023-09-04 16:40:17 +08:00
..
src init 2023-09-04 16:40:17 +08:00
README.md init 2023-09-04 16:40:17 +08:00
pom.xml init 2023-09-04 16:40:17 +08:00

README.md

Sentinel gRPC Adapter

Sentinel gRPC Adapter provides client and server interceptor for gRPC services.

Note that currently the interceptor only supports unary methods in gRPC.

Client Interceptor

Example:

public class ServiceClient {

    private final ManagedChannel channel;

    ServiceClient(String host, int port) {
        this.channel = ManagedChannelBuilder.forAddress(host, port)
            .intercept(new SentinelGrpcClientInterceptor()) // Add the client interceptor.
            .build();
        // Init your stub here.
    }
}

Server Interceptor

Example:

import io.grpc.Server;

Server server = ServerBuilder.forPort(port)
     .addService(new MyServiceImpl()) // Add your service.
     .intercept(new SentinelGrpcServerInterceptor()) // Add the server interceptor.
     .build();