eclipse-vertx / vertx-grpc

Development of the gRPC component for Eclipse Vert.x
Eclipse Public License 2.0
37 stars 23 forks source link

GrpcServer can't be mounted in a Vert.x Web router #84

Closed tsegismont closed 5 months ago

tsegismont commented 6 months ago

The documentation and the 4.3 release blog post indicate that a GrpcServer can be mounted in a Vert.x Web router.

In fact, it is not possible because the gRPC server is a Handler<HttpServerRequest> not a Handler<RoutingContext>. So this blog post example is wrong:

GreeterGrpc.GreeterImplBase service = new GreeterGrpc.GreeterImplBase() {
  @Override
  public void sayHello(HelloRequest request, StreamObserver<HelloReply> responseObserver) {
    responseObserver.onNext(HelloReply.newBuilder().setMessage("Hello " + request.getName()).build());
    responseObserver.onCompleted();
  }
};

GrpcServer grpcServer = GrpcServer.server(vertx);
GrpcServiceBridge serverStub = GrpcServiceBridge.bridge(service);
serverStub.bind(grpcServer);

router.consumes("application/grpc").handler(grpcServer); // does not compile
tsegismont commented 6 months ago

@vietj did I miss anything?

vietj commented 6 months ago

I would like to avoid this dependency of vertx-grpc over vertx-web for various reasons.

Instead we should provide the code return rc -> server.handle(rc.request()) in the documentation, alternatively we could consider having a dependency of vertx-web onto vertx-grpc, but I think that is not necessary.

tsegismont commented 5 months ago

OK, let's fix the documentation and the blog post

tsegismont commented 5 months ago

Fixed by 31d21d8b9709e37ab67c78d03ee48db8c9ed12bf