-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interceptor compression not propagated to real handler #1557
Comments
Can you provide a working example? It's a little hard to tell what you're reporting without some more context |
So basically the problem is with the Grpc Server that is setup with Dagger (client initiating compression works fine). A very basic simple example would be a server, taken from the Dagger article (https://dagger.dev/grpc/servers.html): public class CompressingGreeterServer {
private static final Logger logger = Logger.getLogger(CompressingGreeterServer.class.getName());
@Module(includes = {
GreeterModule.class,
})
static abstract class GreeterGrpcModule {
@Binds
abstract GreeterServiceDefinition provideGreeterServiceDefinition(ServerComponent serverComponent);
@Provides
@ForGrpcService(GreeterGrpc.class)
static List<? extends ServerInterceptor> provideInterceptors() {
return Arrays.asList(new ServerInterceptor() {
@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) {
call.setCompression("gzip");
return next.startCall(call, headers);
}
});
}
}
@Singleton
@Component(modules = {
GreeterUnscopedGrpcServiceModule.class,
GreeterGrpcModule.class,
NettyServerModule.class,
})
interface ServerComponent extends GreeterServiceDefinition {
Server server();
}
private void start() throws IOException, InterruptedException {
int port = 50051;
ServerComponent component =
DaggerCompressingGreeterServer_ServerComponent.builder()
.nettyServerModule(NettyServerModule.bindingToPort(port))
.build();
final Server server = component.server();
server.start();
Runtime.getRuntime()
.addShutdownHook(
new Thread(
() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down Auth Server since JVM is shutting down");
server.shutdown();
System.err.println("*** server shut down");
}));
server.awaitTermination();
logger.info("Server started, listening on " + port);
}
public static void main(String[] args) throws IOException, InterruptedException {
CompressingGreeterServer server = new CompressingGreeterServer();
server.start();
}
} And the Greeter class: @GrpcService(grpcClass = GreeterGrpc.class)
public class Greeter extends GreeterGrpc.GreeterImplBase {
@Override
public void sayHello(HelloRequest request, StreamObserver<HelloReply> responseObserver) {
HelloReply reply = HelloReply.newBuilder().setMessage("Hello: " + request.getName()).build();
responseObserver.onNext(reply);
responseObserver.onCompleted();
}
} But because |
ServerCall.setCompression lost due to dagger.grpc.server.ProxyServerCallHandler.ServerCallAdapter
not propagated to
delegate
, example:The text was updated successfully, but these errors were encountered: