Eric Zhao c92fea5d46 Welcome to the world, Sentinel | 6 年前 | |
---|---|---|
.. | ||
src | 6 年前 | |
README.md | 6 年前 | |
pom.xml | 6 年前 |
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.
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.
}
}
Example:
import io.grpc.Server;
Server server = ServerBuilder.forPort(port)
.addService(new MyServiceImpl()) // Add your service.
.intercept(new SentinelGrpcServerInterceptor()) // Add the server interceptor.
.build();