Sentinel/sentinel-adapter/sentinel-grpc-adapter
Eric Zhao 3de817be10 Update .travis.yml and dependencies to support build with JDK 11
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2018-11-06 21:01:41 +08:00
..
src Enhancement/normalize metric field (#170) 2018-10-11 09:28:43 +08:00
README.md Welcome to the world, Sentinel 2018-07-27 16:34:30 +08:00
pom.xml Update .travis.yml and dependencies to support build with JDK 11 2018-11-06 21:01:41 +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. In some circumstances (e.g. asynchronous call), the RT metrics might not be accurate.

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();