Skip to content

Commit

Permalink
Added exception Handler for Many to Many stream (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x01F4 authored and tsegismont committed Nov 23, 2023
1 parent ed41e6b commit e1848f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public final class {{className}} {
public io.vertx.core.streams.ReadStream<{{outputType}}> {{methodName}}(io.vertx.core.Handler<io.vertx.core.streams.WriteStream<{{inputType}}>> hdlr) {
return io.vertx.grpc.stub.ClientCalls.{{vertxCallsMethodName}}(ctx, hdlr, delegateStub::{{methodName}});
}

public io.vertx.core.streams.ReadStream<{{outputType}}> {{methodName}}WithExceptionHandler(io.vertx.core.Handler<io.vertx.core.streams.WriteStream<{{inputType}}>> hdlr, io.vertx.core.Handler<java.lang.Throwable> exceptionHandler) {
return io.vertx.grpc.stub.ClientCalls.{{vertxCallsMethodName}}(ctx, hdlr, delegateStub::{{methodName}}, exceptionHandler);
}
{{/manyManyMethods}}
}

Expand Down
5 changes: 5 additions & 0 deletions vertx-grpc/src/main/java/io/vertx/grpc/stub/ClientCalls.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ public static <I, O> Future<O> manyToOne(ContextInternal ctx, Handler<WriteStrea
}

public static <I, O> ReadStream<O> manyToMany(ContextInternal ctx, Handler<WriteStream<I>> requestHandler, Function<StreamObserver<O>, StreamObserver<I>> delegate) {
return manyToMany(ctx, requestHandler, delegate, null);
}

public static <I, O> ReadStream<O> manyToMany(ContextInternal ctx, Handler<WriteStream<I>> requestHandler, Function<StreamObserver<O>, StreamObserver<I>> delegate, Handler<Throwable> exceptionHandler) {
StreamObserverReadStream<O> response = new StreamObserverReadStream<>();
response.exceptionHandler(exceptionHandler);
StreamObserver<I> request = delegate.apply(response);
requestHandler.handle(new GrpcWriteStream<>(request));
return response;
Expand Down

0 comments on commit e1848f2

Please sign in to comment.