U - the type of address before resolution (unresolved address)R - the type of address after resolution (resolved address)public abstract class MultiAddressHttpClientBuilder<U,R>
extends Object
StreamingHttpClient instances which have a capacity to call any server based on the parsed
absolute-form URL address information from each StreamingHttpRequest.
It also provides a good set of default settings and configurations, which could be used by most users as-is or could be overridden to address specific use cases.
| Constructor and Description |
|---|
MultiAddressHttpClientBuilder() |
| Modifier and Type | Method and Description |
|---|---|
abstract MultiAddressHttpClientBuilder<U,R> |
appendClientFilter(MultiAddressHttpClientFilterFactory<U> factory)
Appends the filter to the chain of filters used to decorate the
StreamingHttpClient created by this
builder for a given UnresolvedAddress. |
MultiAddressHttpClientBuilder<U,R> |
appendClientFilter(Predicate<StreamingHttpRequest> predicate,
MultiAddressHttpClientFilterFactory<U> factory)
Appends the filter to the chain of filters used to decorate the
StreamingHttpClient created by this
builder for a given UnresolvedAddress, for every request that passes the provided Predicate. |
MultiAddressHttpClientBuilder<U,R> |
appendClientFilter(Predicate<StreamingHttpRequest> predicate,
StreamingHttpClientFilterFactory factory)
Appends the filter to the chain of filters used to decorate the
HttpClient created by this
builder, for every request that passes the provided Predicate. |
abstract MultiAddressHttpClientBuilder<U,R> |
appendClientFilter(StreamingHttpClientFilterFactory factory)
Appends the filter to the chain of filters used to decorate the
HttpClient created by this
builder. |
abstract MultiAddressHttpClientBuilder<U,R> |
appendConnectionFactoryFilter(ConnectionFactoryFilter<R,FilterableStreamingHttpConnection> factory)
Appends the filter to the chain of filters used to decorate the
ConnectionFactory used by this
builder. |
MultiAddressHttpClientBuilder<U,R> |
appendConnectionFilter(Predicate<StreamingHttpRequest> predicate,
StreamingHttpConnectionFilterFactory factory)
Appends the filter to the chain of filters used to decorate the
StreamingHttpConnection created by this
builder, for every request that passes the provided Predicate. |
abstract MultiAddressHttpClientBuilder<U,R> |
appendConnectionFilter(StreamingHttpConnectionFilterFactory factory)
Appends the filter to the chain of filters used to decorate the
StreamingHttpConnection created by this
builder. |
abstract MultiAddressHttpClientBuilder<U,R> |
autoRetryStrategy(AutoRetryStrategyProvider autoRetryStrategyProvider)
Updates the automatic retry strategy for the clients generated by this builder.
|
abstract MultiAddressHttpClientBuilder<U,R> |
bufferAllocator(BufferAllocator allocator)
Sets the
BufferAllocator for all connections created from this builder. |
HttpClient |
build()
Builds a new
HttpClient, using a default ExecutionContext. |
BlockingHttpClient |
buildBlocking()
Creates a new
BlockingHttpClient, using a default ExecutionContext. |
BlockingStreamingHttpClient |
buildBlockingStreaming()
Creates a new
BlockingStreamingHttpClient, using a default ExecutionContext. |
abstract StreamingHttpClient |
buildStreaming()
Builds a new
StreamingHttpClient, using a default ExecutionContext. |
abstract MultiAddressHttpClientBuilder<U,R> |
disableHostHeaderFallback()
Disables automatically setting
Host headers by inferring from the address or HttpMetaData. |
abstract MultiAddressHttpClientBuilder<U,R> |
enableWireLogging(String loggerName)
Enables wire-logging for connections created by this builder.
|
abstract MultiAddressHttpClientBuilder<U,R> |
executionStrategy(HttpExecutionStrategy strategy)
Sets the
HttpExecutionStrategy for all connections created from this builder. |
abstract MultiAddressHttpClientBuilder<U,R> |
ioExecutor(IoExecutor ioExecutor)
Sets the
IoExecutor for all connections created from this builder. |
abstract MultiAddressHttpClientBuilder<U,R> |
loadBalancerFactory(HttpLoadBalancerFactory<R> loadBalancerFactory)
Sets a
HttpLoadBalancerFactory to create LoadBalancer instances. |
abstract MultiAddressHttpClientBuilder<U,R> |
maxRedirects(int maxRedirects)
Sets a maximum number of redirects to follow.
|
abstract HttpClientBuilder<U,R,SDE> |
protocols(HttpProtocolConfig... protocols)
Configurations of various HTTP protocol versions.
|
abstract MultiAddressHttpClientBuilder<U,R> |
secure(BiConsumer<HostAndPort,ClientSecurityConfigurator> sslConfigFunction)
Sets a function that is used for configuring SSL/TLS for https requests.
|
abstract MultiAddressHttpClientBuilder<U,R> |
serviceDiscoverer(ServiceDiscoverer<U,R,? extends ServiceDiscovererEvent<R>> serviceDiscoverer)
Sets a
ServiceDiscoverer to resolve addresses of remote servers to connect to. |
abstract <T> MultiAddressHttpClientBuilder<U,R> |
socketOption(SocketOption<T> option,
T value)
Adds a
SocketOption for all connections created by this builder. |
abstract MultiAddressHttpClientBuilder<U,R> |
unresolvedAddressToHost(Function<U,CharSequence> unresolvedAddressToHostFunction)
Provides a means to convert
U unresolved address type into a CharSequence. |
public abstract MultiAddressHttpClientBuilder<U,R> ioExecutor(IoExecutor ioExecutor)
IoExecutor for all connections created from this builder.ioExecutor - IoExecutor to use.this.public abstract MultiAddressHttpClientBuilder<U,R> executionStrategy(HttpExecutionStrategy strategy)
HttpExecutionStrategy for all connections created from this builder.strategy - HttpExecutionStrategy to use.this.public abstract MultiAddressHttpClientBuilder<U,R> bufferAllocator(BufferAllocator allocator)
BufferAllocator for all connections created from this builder.allocator - BufferAllocator to use.this.public abstract <T> MultiAddressHttpClientBuilder<U,R> socketOption(SocketOption<T> option, T value)
SocketOption for all connections created by this builder.T - the type of the value.option - the option to apply.value - the value.this.StandardSocketOptions,
ServiceTalkSocketOptionspublic abstract MultiAddressHttpClientBuilder<U,R> enableWireLogging(String loggerName)
All wire events will be logged at TRACE level.
loggerName - The name of the logger to log wire events.this.public abstract MultiAddressHttpClientBuilder<U,R> disableHostHeaderFallback()
Host headers by inferring from the address or HttpMetaData.
This setting disables the default filter such that no Host header will be manipulated.
thisunresolvedAddressToHost(Function)public abstract MultiAddressHttpClientBuilder<U,R> secure(BiConsumer<HostAndPort,ClientSecurityConfigurator> sslConfigFunction)
sslConfigFunction - The function to use for configuring SSL/TLS for https requests.thispublic abstract MultiAddressHttpClientBuilder<U,R> appendConnectionFilter(StreamingHttpConnectionFilterFactory factory)
StreamingHttpConnection created by this
builder.
Filtering allows you to wrap a StreamingHttpConnection and modify behavior during request/response
processing
Some potential candidates for filtering include logging, metrics, and decorating responses.
The order of execution of these filters are in order of append. If 3 filters are added as follows:
builder.append(filter1).append(filter2).append(filter3)
making a request to a connection wrapped by this filter chain the order of invocation of these filters will be:
filter1 => filter2 => filter3 => connection
factory - StreamingHttpConnectionFilterFactory to decorate a StreamingHttpConnection for the
purpose of filtering.thispublic MultiAddressHttpClientBuilder<U,R> appendConnectionFilter(Predicate<StreamingHttpRequest> predicate, StreamingHttpConnectionFilterFactory factory)
StreamingHttpConnection created by this
builder, for every request that passes the provided Predicate.
Filtering allows you to wrap a StreamingHttpConnection and modify behavior during request/response
processing
Some potential candidates for filtering include logging, metrics, and decorating responses.
The order of execution of these filters are in order of append. If 3 filters are added as follows:
builder.append(filter1).append(filter2).append(filter3)
making a request to a connection wrapped by this filter chain the order of invocation of these filters will be:
filter1 => filter2 => filter3 => connection
predicate - the Predicate to test if the filter must be applied.factory - StreamingHttpConnectionFilterFactory to decorate a StreamingHttpConnection for the
purpose of filtering.thispublic abstract MultiAddressHttpClientBuilder<U,R> appendConnectionFactoryFilter(ConnectionFactoryFilter<R,FilterableStreamingHttpConnection> factory)
ConnectionFactory used by this
builder.
Filtering allows you to wrap a ConnectionFactory and modify behavior of
ConnectionFactory.newConnection(Object).
Some potential candidates for filtering include logging and metrics.
The order of execution of these filters are in order of append. If 3 filters are added as follows:
builder.append(filter1).append(filter2).append(filter3)
Calling ConnectionFactory wrapped by this filter chain, the order of invocation of these filters will be:
filter1 => filter2 => filter3 => original connection factory
factory - ConnectionFactoryFilter to use.thispublic abstract MultiAddressHttpClientBuilder<U,R> autoRetryStrategy(AutoRetryStrategyProvider autoRetryStrategyProvider)
AutoRetryStrategyProvider. These retries are not a
substitute for user level retries which are designed to infer retry decisions based on request/error information.
Typically such user level retries are done using filters (eg:
appendClientFilter(StreamingHttpClientFilterFactory)) but can also be done differently per request
(eg: by using Single.retry(BiIntPredicate)).autoRetryStrategyProvider - AutoRetryStrategyProvider for the automatic retry strategy.thispublic abstract MultiAddressHttpClientBuilder<U,R> serviceDiscoverer(ServiceDiscoverer<U,R,? extends ServiceDiscovererEvent<R>> serviceDiscoverer)
ServiceDiscoverer to resolve addresses of remote servers to connect to.serviceDiscoverer - The ServiceDiscoverer to resolve addresses of remote servers to connect to.
Lifecycle of the provided ServiceDiscoverer is managed externally and it should be
closed after all built StreamingHttpClients will be closed and
this ServiceDiscoverer is no longer needed.this.public abstract MultiAddressHttpClientBuilder<U,R> loadBalancerFactory(HttpLoadBalancerFactory<R> loadBalancerFactory)
HttpLoadBalancerFactory to create LoadBalancer instances.loadBalancerFactory - HttpLoadBalancerFactory to create LoadBalancer instances.this.public abstract MultiAddressHttpClientBuilder<U,R> unresolvedAddressToHost(Function<U,CharSequence> unresolvedAddressToHostFunction)
U unresolved address type into a CharSequence.
An example of where this maybe used is to convert the U to a default host header. It may also
be used in the event of proxying.unresolvedAddressToHostFunction - invoked to convert the U unresolved address type into a
CharSequence suitable for use in
Host Header format.thispublic abstract MultiAddressHttpClientBuilder<U,R> appendClientFilter(StreamingHttpClientFilterFactory factory)
HttpClient created by this
builder.
Note this method will be used to decorate the result of build() before it is
returned to the user.
The order of execution of these filters are in order of append. If 3 filters are added as follows:
builder.append(filter1).append(filter2).append(filter3)
making a request to a client wrapped by this filter chain the order of invocation of these filters will be:
filter1 => filter2 => filter3 => client
factory - StreamingHttpClientFilterFactory to decorate a HttpClient for the purpose of
filtering.thispublic MultiAddressHttpClientBuilder<U,R> appendClientFilter(Predicate<StreamingHttpRequest> predicate, StreamingHttpClientFilterFactory factory)
HttpClient created by this
builder, for every request that passes the provided Predicate.
Note this method will be used to decorate the result of build() before it is
returned to the user.
The order of execution of these filters are in order of append. If 3 filters are added as follows:
builder.append(filter1).append(filter2).append(filter3)
making a request to a client wrapped by this filter chain the order of invocation of these filters will be:
filter1 => filter2 => filter3 => client
predicate - the Predicate to test if the filter must be applied.factory - StreamingHttpClientFilterFactory to decorate a HttpClient for the purpose of
filtering.thispublic abstract MultiAddressHttpClientBuilder<U,R> appendClientFilter(MultiAddressHttpClientFilterFactory<U> factory)
StreamingHttpClient created by this
builder for a given UnresolvedAddress.
Note this method will be used to decorate the result of buildStreaming() before it is
returned to the user.
The order of execution of these filters are in order of append. If 3 filters are added as follows:
builder.append(filter1).append(filter2).append(filter3)
Making a request to a client wrapped by this filter chain the order of invocation of these filters will be:
filter1 => filter2 => filter3 => client
factory - MultiAddressHttpClientFilterFactory to decorate a StreamingHttpClient for the
purpose of filtering.thispublic MultiAddressHttpClientBuilder<U,R> appendClientFilter(Predicate<StreamingHttpRequest> predicate, MultiAddressHttpClientFilterFactory<U> factory)
StreamingHttpClient created by this
builder for a given UnresolvedAddress, for every request that passes the provided Predicate.
Note this method will be used to decorate the result of buildStreaming() before it is
returned to the user.
The order of execution of these filters are in order of append. If 3 filters are added as follows:
builder.append(filter1).append(filter2).append(filter3)
Making a request to a client wrapped by this filter chain the order of invocation of these filters will be:
filter1 => filter2 => filter3 => client
predicate - the Predicate to test if the filter must be applied.factory - MultiAddressHttpClientFilterFactory to decorate a StreamingHttpClient for the
purpose of filtering.thispublic abstract MultiAddressHttpClientBuilder<U,R> maxRedirects(int maxRedirects)
maxRedirects - A maximum number of redirects to follow. 0 disables redirects.this.public abstract HttpClientBuilder<U,R,SDE> protocols(HttpProtocolConfig... protocols)
Note: the order of specified protocols will reflect on priorities for ALPN in case the connections are secured.
protocols - HttpProtocolConfig for each protocol that should be supported.this.public abstract StreamingHttpClient buildStreaming()
StreamingHttpClient, using a default ExecutionContext.StreamingHttpClientpublic final HttpClient build()
HttpClient, using a default ExecutionContext.HttpClientpublic final BlockingStreamingHttpClient buildBlockingStreaming()
BlockingStreamingHttpClient, using a default ExecutionContext.BlockingStreamingHttpClientpublic final BlockingHttpClient buildBlocking()
BlockingHttpClient, using a default ExecutionContext.BlockingHttpClient