You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "szetszwo (via GitHub)" <gi...@apache.org> on 2023/09/14 17:31:24 UTC
[GitHub] [ratis] szetszwo commented on a diff in pull request #738: RATIS-1701. Add new Server RPC: readIndex
szetszwo commented on code in PR #738:
URL: https://github.com/apache/ratis/pull/738#discussion_r1326308560
##########
ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcServerProtocolService.java:
##########
@@ -197,6 +197,20 @@ public void startLeaderElection(StartLeaderElectionRequestProto request,
}
}
+ @Override
+ public void readIndex(ReadIndexRequestProto request, StreamObserver<ReadIndexReplyProto> responseObserver) {
+ try {
+ server.readIndexAsync(request).thenAccept(reply -> {
Review Comment:
Good point! We probably should use `whenComplete` to call `onError`.
```java
server.readIndexAsync(request).whenComplete((reply, e) -> {
if (reply != null) {
responseObserver.onNext(reply);
responseObserver.onCompleted();
} else {
if (e == null) {
e = new IOException("Failed to get readIndex: request=" + request);
}
responseObserver.onError(GrpcUtil.wrapException(e));
}
});
```
--
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: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org