Package com.algolia.search
Class ApacheHttpRequester
- java.lang.Object
-
- com.algolia.search.ApacheHttpRequester
-
- All Implemented Interfaces:
HttpRequester
public final class ApacheHttpRequester extends Object implements HttpRequester
The Algolia http requester is a wrapper on top of the HttpAsyncClient of Apache. It's an implementation ofHttpRequesterIt takes anHttpRequestas input. It returns anHttpResponse.
-
-
Constructor Summary
Constructors Constructor Description ApacheHttpRequester(ConfigBase config)ApacheHttpRequester(ConfigBase config, org.apache.http.impl.nio.client.HttpAsyncClientBuilder builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the http client.CompletableFuture<HttpResponse>performRequestAsync(HttpRequest request)Sends the http request asynchronously to the API If the request is time out it creates a new response object with timeout set to true Otherwise it throws a run time exception
-
-
-
Constructor Detail
-
ApacheHttpRequester
public ApacheHttpRequester(@Nonnull ConfigBase config)
-
ApacheHttpRequester
public ApacheHttpRequester(@Nonnull ConfigBase config, @Nonnull org.apache.http.impl.nio.client.HttpAsyncClientBuilder builder)
-
-
Method Detail
-
performRequestAsync
public CompletableFuture<HttpResponse> performRequestAsync(HttpRequest request)
Sends the http request asynchronously to the API If the request is time out it creates a new response object with timeout set to true Otherwise it throws a run time exception- Specified by:
performRequestAsyncin interfaceHttpRequester- Parameters:
request- the request to send- Throws:
AlgoliaRuntimeException- When an error occurred while sending the request
-
close
public void close() throws IOExceptionCloses the http client.- Specified by:
closein interfaceHttpRequester- Throws:
IOException
-
-