ptupitsyn commented on a change in pull request #8174:
URL: https://github.com/apache/ignite/pull/8174#discussion_r494134188
##########
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:
I agree, but this behavior is consistent with sync API, I don't think we
should have different behavior for sync and async API.
----------------------------------------------------------------
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]