opensearch-sdk-java
opensearch-sdk-java copied to clipboard
[FEATURE] Add Async version of client.execute to SDKClient and friends
Is your feature request related to a problem?
To support AD Extension work we have implemented client.execute(action, request, actionListener).
To support future development we need the async version: future = client.execute(action, request).
What solution would you like?
So current code that looks like this:
CompletableFuture<ExtensionActionResponse> futureResponse = new CompletableFuture<>();
client.execute(
ProxyAction.INSTANCE,
proxyActionRequest,
ActionListener.wrap(r -> futureResponse.complete(r), e -> futureResponse.completeExceptionally(e))
);
Would look like this:
CompletableFuture<ExtensionActionResponse> futureResponse = client.execute(
ProxyAction.INSTANCE,
proxyActionRequest
);
This should be a relatively simple method overload moving the ActionListener.wrap() bits into the new method and adding a return value.
This should be added to SDKClient and SDKRestClient as a minimum.
What alternatives have you considered?
Forcing people to wrap action listeners all the time. Ugh!
Do you have any additional context?
The method signature should probably match AbstractClient except replacing the ActionFuture with the more useful CompletableFuture
public final <Request extends ActionRequest, Response extends ActionResponse> ActionFuture<Response> execute(
ActionType<Response> action,
Request request
) { ... }
I would like to take it
Hey @MehulBatra, it's all yours!
@MehulBatra are you still working on this?
yes