szetszwo commented on code in PR #1481:
URL: https://github.com/apache/ratis/pull/1481#discussion_r3438134071


##########
ratis-client/src/main/java/org/apache/ratis/client/DataStreamClientRpc.java:
##########
@@ -36,4 +37,11 @@ default CompletableFuture<DataStreamReply> 
streamAsync(DataStreamRequest request
     throw new UnsupportedOperationException(getClass() + " does not support "
         + JavaUtils.getCurrentStackTraceElement().getMethodName());
   }
+
+  /** Async call to send a request and receive multiple replies for the 
request. */
+  default CompletableFuture<DataStreamReply> streamAsync(
+      DataStreamRequest request, Consumer<DataStreamReply> replyConsumer) {

Review Comment:
   @peterxcli ,  Let's borrow the idea from [gRPC 
StreamObserver](https://grpc.github.io/grpc-java/javadoc/io/grpc/stub/StreamObserver.html)
 and add a similar interface.  It is more flexible for future changes.
   ```java
   //ratis-common
   package org.apache.ratis.datastream;
   
   /** An interface similar to gRPC {@link 
org.apache.ratis.thirdparty.io.grpc.stub.StreamObserver}. */
   public interface DataStreamObserver<V> {
     void onNext(V value);
   
     // see if onError(Throwable) and onCompleted() are useful.  Or we may add 
them later.
   }
   ```
   
   ```java
   //DataStreamClientRpc
     /** Async call to send a request and receive multiple replies for the 
request. */
     default CompletableFuture<DataStreamReply> streamAsync(DataStreamRequest 
request,
         DataStreamObserver<DataStreamReplyByteBuf> replyHandler) {
       throw new UnsupportedOperationException(getClass() + " does not support "
           + JavaUtils.getCurrentStackTraceElement().getMethodName());
     }
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to