Interface TransportHttpClient
- All Known Implementing Classes:
Rest5ClientHttpClient,RestClientHttpClient
public interface TransportHttpClient
Minimal http client interface needed to implement an Elasticsearch transport.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classA node/host to send requests to.static classAn http request.static interfaceAn http response. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close this client, freeing associated resources.default TransportOptionscreateOptions(TransportOptions options) Create a client-specific options value from an existing option object.performRequest(String endpointId, TransportHttpClient.Node node, TransportHttpClient.Request request, TransportOptions options) Perform a blocking request.performRequestAsync(String endpointId, TransportHttpClient.Node node, TransportHttpClient.Request request, TransportOptions options) Perform an asynchronous request.
-
Method Details
-
createOptions
Create a client-specific options value from an existing option object. Ifnull, this must create the default options to which additional options can be added.This method allows implementations to return subclasses with more features (that applications can use by downcasting the result). By default, it will use
DefaultTransportOptions. -
performRequest
TransportHttpClient.Response performRequest(String endpointId, @Nullable TransportHttpClient.Node node, TransportHttpClient.Request request, TransportOptions options) throws IOException Perform a blocking request.- Parameters:
endpointId- the endpoint identifier. Can be used to have specific strategies depending on the endpoint.node- the node to send the request to. Ifnull, the implementation has to choose which node to send the request to, or throw anIllegalArgumentException.request- the requestoptions- additional options for the http client. Headers and request parameters set in the options have precedence over those defined by the request and should replace them in the final request sent.- Returns:
- the response
- Throws:
IllegalArgumentException- ifnodeisis nulland the implementation cannot decide of a node to use.IOException
-
performRequestAsync
CompletableFuture<TransportHttpClient.Response> performRequestAsync(String endpointId, @Nullable TransportHttpClient.Node node, TransportHttpClient.Request request, TransportOptions options) Perform an asynchronous request.Implementations should return a
CompletableFuturewhose cancellation also cancels any http request in flight and frees the associated resources. This allows applications to implement scenarios like timeouts or "first to respond" fan-out without leaking resources.- Parameters:
endpointId- the endpoint identifier. Can be used to have specific strategies depending on the endpoint.node- the node to send the request to. Ifnull, the implementation has to choose which node to send the request to, or throw anIllegalArgumentException.request- the requestoptions- additional options for the http client. Headers and request parameters set in the options have precedence over those defined by the request and should replace them in the final request sent.- Returns:
- a future that will be completed with the response.
-
close
Close this client, freeing associated resources.- Throws:
IOException
-