isapego commented on a change in pull request #8174:
URL: https://github.com/apache/ignite/pull/8174#discussion_r494136187
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
##########
@@ -210,14 +213,95 @@
throw failure;
}
+ /**
+ * Send request and handle response asynchronously.
+ */
+ public <T> IgniteClientFuture<T> serviceAsync(
+ ClientOperation op,
+ Consumer<PayloadOutputChannel> payloadWriter,
+ Function<PayloadInputChannel, T> payloadReader
+ ) throws ClientException, ClientError {
+ CompletableFuture<T> fut = new CompletableFuture<>();
+
+ ClientChannel ch = channel();
+
+ ch.serviceAsync(op, payloadWriter, payloadReader).handle((res, err) ->
+ handleServiceAsync(op, payloadWriter, payloadReader, fut,
null, null, ch, res, err));
+
+ return new IgniteClientFutureImpl<>(fut);
+ }
+
+ /**
+ * Handles serviceAsync results and retries as needed.
+ */
+ private <T> Object handleServiceAsync(ClientOperation op,
+ Consumer<PayloadOutputChannel>
payloadWriter,
+ Function<PayloadInputChannel, T>
payloadReader,
+ CompletableFuture<T> fut,
+ ClientConnectionException failure,
+ AtomicInteger chIdx,
+ ClientChannel ch,
+ T res,
+ Throwable err) {
+ if (err == null) {
+ fut.complete(res);
+ return null;
+ }
+
+ if (err instanceof ClientConnectionException) {
Review comment:
Well, OK then
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]