eclipse-vertx / vertx-grpc

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

Fix the problem that arises when adding the vertx-grpc module to vertx-rx #33

Closed lwlee2608 closed 1 year ago

lwlee2608 commented 1 year ago

When i try to use grpc-server in my reactive vertx application.

GrpcServer grpcServer = GrpcServer.server(vertx);
vertx.createHttpServer()
        .requestHandler(grpcServer)
        .rxListen(grpcPort);

I encountered the following error:

incompatible types: io.vertx.grpc.server.GrpcServer cannot be converted to io.vertx.core.Handler<io.vertx.reactivex.core.http.HttpServerRequest>

I am seeking to implement RxJava support for vertx-grpc. I have incorporated the vertx-grpc module into the vertx-rx generation process to achieve this. However, I am encountering numerous errors, such as

end() in io.vertx.rxjava.grpc.server.GrpcServerResponse cannot implement end() in io.vertx.rxjava.core.streams.WriteStream
write(Req) in io.vertx.rxjava.grpc.client.GrpcClientRequest cannot implement write(T) in io.vertx.rxjava.core.streams.WriteStream
write(Resp) in io.vertx.rxjava.grpc.server.GrpcServerResponse cannot implement write(T) in io.vertx.rxjava.core.streams.WriteStream
... 

This pull request intends to resolve all those errors. I've confirmed that both the generated reactive grpc-server and grpc-client functions are operational. However, I need to alter the @ModuleGen setting of useFutures to false. May I proceed with this change?

lwlee2608 commented 1 year ago

Here is the complete error message I am encountering in vertx-rx without the necessary fixes:

[ERROR] /home/lwlee2608/src/github/vertx/vertx-x3/vertx-rx/rx-java/target/generated-sources/apt/io/vertx/rxjava/grpc/common/GrpcWriteStream.java:[40,8] io.vertx.rxjava.grpc.common.GrpcWriteStream is not abstract and does not override abstract method rxEnd(T) in io.vertx.rxjava.core.streams.WriteStream
[ERROR] /home/lwlee2608/src/github/vertx/vertx-x3/vertx-rx/rx-java/target/generated-sources/apt/io/vertx/rxjava/grpc/common/GrpcWriteStream.java:[127,47] end(T) in io.vertx.rxjava.grpc.common.GrpcWriteStream cannot implement end(T) in io.vertx.rxjava.core.streams.WriteStream
[ERROR]   return type io.vertx.core.Future<java.lang.Void> is not compatible with void
[ERROR] /home/lwlee2608/src/github/vertx/vertx-x3/vertx-rx/rx-java/target/generated-sources/apt/io/vertx/rxjava/grpc/common/GrpcWriteStream.java:[117,47] end() in io.vertx.rxjava.grpc.common.GrpcWriteStream cannot implement end() in io.vertx.rxjava.core.streams.WriteStream
[ERROR]   return type io.vertx.core.Future<java.lang.Void> is not compatible with void
[ERROR] /home/lwlee2608/src/github/vertx/vertx-x3/vertx-rx/rx-java/target/generated-sources/apt/io/vertx/rxjava/grpc/common/GrpcWriteStream.java:[106,47] write(T) in io.vertx.rxjava.grpc.common.GrpcWriteStream cannot implement write(T) in io.vertx.rxjava.core.streams.WriteStream
[ERROR]   return type io.vertx.core.Future<java.lang.Void> is not compatible with void
[ERROR] /home/lwlee2608/src/github/vertx/vertx-x3/vertx-rx/rx-java/target/generated-sources/apt/io/vertx/rxjava/grpc/client/GrpcClientRequest.java:[149,47] end(Req) in io.vertx.rxjava.grpc.client.GrpcClientRequest cannot implement end(T) in io.vertx.rxjava.core.streams.WriteStream
[ERROR]   return type io.vertx.core.Future<java.lang.Void> is not compatible with void
[ERROR] /home/lwlee2608/src/github/vertx/vertx-x3/vertx-rx/rx-java/target/generated-sources/apt/io/vertx/rxjava/grpc/client/GrpcClientRequest.java:[139,47] end() in io.vertx.rxjava.grpc.client.GrpcClientRequest cannot implement end() in io.vertx.rxjava.core.streams.WriteStream
[ERROR]   return type io.vertx.core.Future<java.lang.Void> is not compatible with void
[ERROR] /home/lwlee2608/src/github/vertx/vertx-x3/vertx-rx/rx-java/target/generated-sources/apt/io/vertx/rxjava/grpc/client/GrpcClientRequest.java:[128,47] write(Req) in io.vertx.rxjava.grpc.client.GrpcClientRequest cannot implement write(T) in io.vertx.rxjava.core.streams.WriteStream
[ERROR]   return type io.vertx.core.Future<java.lang.Void> is not compatible with void
[ERROR] /home/lwlee2608/src/github/vertx/vertx-x3/vertx-rx/rx-java/target/generated-sources/apt/io/vertx/rxjava/grpc/common/GrpcReadStream.java:[40,8] io.vertx.rxjava.grpc.common.GrpcReadStream is not abstract and does not override abstract method rxPipeTo(io.vertx.rxjava.core.streams.WriteStream<T>) in io.vertx.rxjava.core.streams.ReadStream
[ERROR] /home/lwlee2608/src/github/vertx/vertx-x3/vertx-rx/rx-java/target/generated-sources/apt/io/vertx/rxjava/grpc/common/GrpcReadStream.java:[107,47] pipeTo(io.vertx.rxjava.core.streams.WriteStream<T>) in io.vertx.rxjava.grpc.common.GrpcReadStream cannot implement pipeTo(io.vertx.rxjava.core.streams.WriteStream<T>) in io.vertx.rxjava.core.streams.ReadStream
[ERROR]   return type io.vertx.core.Future<java.lang.Void> is not compatible with void
[ERROR] /home/lwlee2608/src/github/vertx/vertx-x3/vertx-rx/rx-java/target/generated-sources/apt/io/vertx/rxjava/grpc/client/GrpcClientResponse.java:[121,47] pipeTo(io.vertx.rxjava.core.streams.WriteStream<Resp>) in io.vertx.rxjava.grpc.client.GrpcClientResponse cannot implement pipeTo(io.vertx.rxjava.core.streams.WriteStream<T>) in io.vertx.rxjava.core.streams.ReadStream
[ERROR]   return type io.vertx.core.Future<java.lang.Void> is not compatible with void
[ERROR] /home/lwlee2608/src/github/vertx/vertx-x3/vertx-rx/rx-java/target/generated-sources/apt/io/vertx/rxjava/grpc/server/GrpcServerRequest.java:[111,47] pipeTo(io.vertx.rxjava.core.streams.WriteStream<Req>) in io.vertx.rxjava.grpc.server.GrpcServerRequest cannot implement pipeTo(io.vertx.rxjava.core.streams.WriteStream<T>) in io.vertx.rxjava.core.streams.ReadStream
[ERROR]   return type io.vertx.core.Future<java.lang.Void> is not compatible with void
[ERROR] /home/lwlee2608/src/github/vertx/vertx-x3/vertx-rx/rx-java/target/generated-sources/apt/io/vertx/rxjava/grpc/server/GrpcServerResponse.java:[131,47] end(Resp) in io.vertx.rxjava.grpc.server.GrpcServerResponse cannot implement end(T) in io.vertx.rxjava.core.streams.WriteStream
[ERROR]   return type io.vertx.core.Future<java.lang.Void> is not compatible with void
[ERROR] /home/lwlee2608/src/github/vertx/vertx-x3/vertx-rx/rx-java/target/generated-sources/apt/io/vertx/rxjava/grpc/server/GrpcServerResponse.java:[121,47] end() in io.vertx.rxjava.grpc.server.GrpcServerResponse cannot implement end() in io.vertx.rxjava.core.streams.WriteStream
[ERROR]   return type io.vertx.core.Future<java.lang.Void> is not compatible with void
[ERROR] /home/lwlee2608/src/github/vertx/vertx-x3/vertx-rx/rx-java/target/generated-sources/apt/io/vertx/rxjava/grpc/server/GrpcServerResponse.java:[110,47] write(Resp) in io.vertx.rxjava.grpc.server.GrpcServerResponse cannot implement write(T) in io.vertx.rxjava.core.streams.WriteStream
[ERROR]   return type io.vertx.core.Future<java.lang.Void> is not compatible with void
vietj commented 1 year ago

I would like to avoid using non futures with the new grpc module, can you try instead to override the offending method in the interfaces and mark them as @GenIgnore instead ?

lwlee2608 commented 1 year ago

@vietj thank you for your time.

The problem with that is that the generated reactivex.GrpcWriteStream implements interface reactivex.Writestream, which forces me to implement rxWrite() and rxEnd(). As far as I know, these methods will only be generated from asyncHandler. The same applies to GrpcReadStream force me to implement rxPipeTo().

Is there any way to generate these rxFunctions from Futures?

vietj commented 1 year ago

I think we should fix the RX java project to generate from future as well then ?

lwlee2608 commented 1 year ago

I agree, I personally prefer Future than Handler too. If it is not too difficult. I can help with that. But I worry about the scale of its impact. Let me know your plan.

vietj commented 1 year ago

fixed in codegen and vertx-rx