grpc启用压缩gzip
grpc server端
NettyServerBuilder serverBuilder = NettyServerBuilder.forPort(grpcServerPort) .intercept(new ServerInterceptor() {
private final String COMPRESSION = "gzip";
@Override
public <ReqT, RespT> Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers,
ServerCallHandler<ReqT, RespT> next) {
call.setCompression(COMPRESSION);
return next.startCall(call, headers);
}
}).bossEventLoopGroup(boss).workerEventLoopGroup(worker).channelType(channelType).directExecutor();
grpc client端
profileTaskStub = ProfileTaskGrpc.newStub(channel).withCompression("gzip");
以上是 grpc启用压缩gzip 的全部内容, 来源链接: utcz.com/z/518787.html