rishisankar commented on a change in pull request #1770: URL: https://github.com/apache/lucene-solr/pull/1770#discussion_r474390018
########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java ########## @@ -1290,6 +1295,39 @@ public SolrDocumentList getById(Collection<String> ids, SolrParams params) throw return request(request, null); } + /** + * Execute an asynchronous request against a Solr server for a given collection. + * This is only currently supported on the {@link Http2SolrClient} and {@link CloudHttp2SolrClient} for now. + * + * @param request the request to execute + * @param collection the collection to execute the request against + * + * @return a {@link CompletableFuture} that tracks the progress of the async request. Supports cancelling requests via + * {@link CompletableFuture#cancel(boolean)}, adding callbacks/error handling using {@link CompletableFuture#whenComplete(BiConsumer)} + * and {@link CompletableFuture#exceptionally(Function)} methods, and other CompletableFuture functionality. Will + * complete exceptionally in case of either an {@link IOException} or {@link SolrServerException} during the request. + * Once completed, the CompletableFuture will contain a {@link NamedList} with the response from the server. + */ + public CompletableFuture<NamedList<Object>> requestAsync(final SolrRequest<?> request, String collection) { + throw new UnsupportedOperationException("Async requests not supported on this Solr Client."); + } + + /** + * Execute an asynchronous request against a Solr server using the request's collection parameter. + * This is only currently supported on the {@link Http2SolrClient} and {@link CloudHttp2SolrClient} for now. + * + * @param request the request to execute + * + * @return a {@link CompletableFuture} that tracks the progress of the async request. Supports cancelling requests via + * {@link CompletableFuture#cancel(boolean)}, adding callbacks/error handling using {@link CompletableFuture#whenComplete(BiConsumer)} + * and {@link CompletableFuture#exceptionally(Function)} methods, and other CompletableFuture functionality. Will + * complete exceptionally in case of either an {@link IOException} or {@link SolrServerException} during the request. + * Once completed, the CompletableFuture will contain a {@link NamedList} with the response from the server. + */ + public CompletableFuture<NamedList<Object>> requestAsync(final SolrRequest<?> request) { Review comment: I was wondering about that as well - my reason for putting it here was that if other client subclasses later implement it as well, I think having the API be standardized for all SolrClient subclasses would be good. But it would probably be better if a default implementation is added rather than throwing an error (perhaps by adding a separate `setExecutor` method that a user could call and have the default impl use that user-provided executor. Or initializing an executor in this class). ---------------------------------------------------------------- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org