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.
| Modifier and Type | Class and Description |
|---|---|
static interface |
MultiAddressHttpClientBuilder.SingleAddressInitializer<U,R>
Initializes the
SingleAddressHttpClientBuilder for each new client. |
| Constructor and Description |
|---|
MultiAddressHttpClientBuilder() |
public abstract MultiAddressHttpClientBuilder<U,R> ioExecutor(IoExecutor ioExecutor)
IoExecutor for all connections created from this builder.ioExecutor - IoExecutor to use.this.public MultiAddressHttpClientBuilder<U,R> executor(Executor executor)
Executor for all connections created from this builder.executor - Executor 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.@Deprecated public abstract <T> MultiAddressHttpClientBuilder<U,R> socketOption(SocketOption<T> option, T value)
initializer(SingleAddressInitializer) and
SingleAddressHttpClientBuilder.socketOption(SocketOption, Object) on the last argument of
MultiAddressHttpClientBuilder.SingleAddressInitializer.initialize(String, Object, SingleAddressHttpClientBuilder).SocketOption for all connections created by this builder.T - the type of the value.option - the option to apply.value - the value.this.StandardSocketOptions,
ServiceTalkSocketOptions@Deprecated public abstract MultiAddressHttpClientBuilder<U,R> enableWireLogging(String loggerName)
loggerName - The name of the logger to log wire events.this.@Deprecated public abstract MultiAddressHttpClientBuilder<U,R> enableWireLogging(String loggerName, LogLevel logLevel, BooleanSupplier logUserData)
initializer(SingleAddressInitializer) and
SingleAddressHttpClientBuilder.enableWireLogging(String, LogLevel, BooleanSupplier) on the last argument
of MultiAddressHttpClientBuilder.SingleAddressInitializer.initialize(String, Object, SingleAddressHttpClientBuilder).loggerName - The name of the logger to log wire events.logLevel - The level to log at.logUserData - true to include user data (e.g. data, headers, etc.). false to exclude user
data and log only network events.this.@Deprecated public abstract MultiAddressHttpClientBuilder<U,R> protocols(HttpProtocolConfig... protocols)
initializer(SingleAddressInitializer) and
SingleAddressHttpClientBuilder.protocols(HttpProtocolConfig...) on the last argument of
MultiAddressHttpClientBuilder.SingleAddressInitializer.initialize(String, Object, SingleAddressHttpClientBuilder).Note: the order of specified protocols will reflect on priorities for ALPN in case the connections use TLS.
protocols - HttpProtocolConfig for each protocol that should be supported.this.@Deprecated public abstract MultiAddressHttpClientBuilder<U,R> disableHostHeaderFallback()
initializer(SingleAddressInitializer) and
SingleAddressHttpClientBuilder.disableHostHeaderFallback() on the last argument of
MultiAddressHttpClientBuilder.SingleAddressInitializer.initialize(String, Object, SingleAddressHttpClientBuilder).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)@Deprecated public abstract MultiAddressHttpClientBuilder<U,R> allowDropResponseTrailers(boolean allowDrop)
initializer(SingleAddressInitializer) and
SingleAddressHttpClientBuilder.allowDropResponseTrailers(boolean) on the last argument of
MultiAddressHttpClientBuilder.SingleAddressInitializer.initialize(String, Object, SingleAddressHttpClientBuilder).allowDrop - true if response
trailers are allowed to be dropped.this@Deprecated public abstract MultiAddressHttpClientBuilder<U,R> secure(BiConsumer<HostAndPort,ClientSecurityConfigurator> sslConfigFunction)
initializer(SingleAddressInitializer) and create a
MultiAddressHttpClientBuilder.SingleAddressInitializer that invokes SingleAddressHttpClientBuilder.sslConfig(ClientSslConfig).sslConfigFunction - The function to use for configuring SSL/TLS for https requests.thispublic abstract MultiAddressHttpClientBuilder<U,R> initializer(MultiAddressHttpClientBuilder.SingleAddressInitializer<U,R> initializer)
StreamingHttpClient that is built.initializer - Initializes the SingleAddressHttpClientBuilder used to build new
StreamingHttpClients.this@Deprecated public abstract MultiAddressHttpClientBuilder<U,R> appendConnectionFilter(StreamingHttpConnectionFilterFactory factory)
initializer(SingleAddressInitializer) and
SingleAddressHttpClientBuilder.appendConnectionFilter(StreamingHttpConnectionFilterFactory) on the last
argument of MultiAddressHttpClientBuilder.SingleAddressInitializer.initialize(String, Object, SingleAddressHttpClientBuilder).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.this@Deprecated public MultiAddressHttpClientBuilder<U,R> appendConnectionFilter(Predicate<StreamingHttpRequest> predicate, StreamingHttpConnectionFilterFactory factory)
initializer(SingleAddressInitializer) and
SingleAddressHttpClientBuilder.appendConnectionFilter(Predicate, StreamingHttpConnectionFilterFactory) on
the last argument of MultiAddressHttpClientBuilder.SingleAddressInitializer.initialize(String, Object, SingleAddressHttpClientBuilder).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.this@Deprecated public abstract MultiAddressHttpClientBuilder<U,R> appendConnectionFactoryFilter(ConnectionFactoryFilter<R,FilterableStreamingHttpConnection> factory)
initializer(SingleAddressInitializer) and
SingleAddressHttpClientBuilder.appendConnectionFactoryFilter(ConnectionFactoryFilter) on the last
argument of MultiAddressHttpClientBuilder.SingleAddressInitializer.initialize(String, Object, SingleAddressHttpClientBuilder).ConnectionFactory used by this
builder.
Filtering allows you to wrap a ConnectionFactory and modify behavior of
ConnectionFactory.newConnection(Object, TransportObserver).
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.this@Deprecated public abstract MultiAddressHttpClientBuilder<U,R> autoRetryStrategy(AutoRetryStrategyProvider autoRetryStrategyProvider)
initializer(SingleAddressInitializer) and
SingleAddressHttpClientBuilder.autoRetryStrategy(AutoRetryStrategyProvider) on the last
argument of MultiAddressHttpClientBuilder.SingleAddressInitializer.initialize(String, Object, SingleAddressHttpClientBuilder).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.thisDefaultAutoRetryStrategyProvider@Deprecated public abstract MultiAddressHttpClientBuilder<U,R> serviceDiscoverer(ServiceDiscoverer<U,R,ServiceDiscovererEvent<R>> serviceDiscoverer)
initializer(SingleAddressInitializer) and
SingleAddressHttpClientBuilder.serviceDiscoverer(ServiceDiscoverer) on the last
argument of MultiAddressHttpClientBuilder.SingleAddressInitializer.initialize(String, Object, SingleAddressHttpClientBuilder).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.@Deprecated public abstract MultiAddressHttpClientBuilder<U,R> retryServiceDiscoveryErrors(ServiceDiscoveryRetryStrategy<R,ServiceDiscovererEvent<R>> retryStrategy)
initializer(SingleAddressInitializer) and
BaseSingleAddressHttpClientBuilder.retryServiceDiscoveryErrors(ServiceDiscoveryRetryStrategy) on the last
argument of MultiAddressHttpClientBuilder.SingleAddressInitializer.initialize(String, Object, SingleAddressHttpClientBuilder).ServiceDiscoverer.
Note, calling this method will unset the value provided via
retryServiceDiscoveryErrors(BiIntFunction) if it was called before.
retryStrategy - a retry strategy to retry errors emitted by ServiceDiscoverer.this.DefaultServiceDiscoveryRetryStrategy.Builder@Deprecated public abstract MultiAddressHttpClientBuilder<U,R> loadBalancerFactory(HttpLoadBalancerFactory<R> loadBalancerFactory)
initializer(SingleAddressInitializer) and
SingleAddressHttpClientBuilder.loadBalancerFactory(HttpLoadBalancerFactory) on the last
argument of MultiAddressHttpClientBuilder.SingleAddressInitializer.initialize(String, Object, SingleAddressHttpClientBuilder).HttpLoadBalancerFactory to create LoadBalancer instances.loadBalancerFactory - HttpLoadBalancerFactory to create LoadBalancer instances.this.@Deprecated public abstract MultiAddressHttpClientBuilder<U,R> unresolvedAddressToHost(Function<U,CharSequence> unresolvedAddressToHostFunction)
initializer(SingleAddressInitializer) and
SingleAddressHttpClientBuilder.unresolvedAddressToHost(Function) on the last
argument of MultiAddressHttpClientBuilder.SingleAddressInitializer.initialize(String, Object, SingleAddressHttpClientBuilder).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.this@Deprecated public abstract MultiAddressHttpClientBuilder<U,R> appendClientFilter(StreamingHttpClientFilterFactory factory)
initializer(SingleAddressInitializer) and
SingleAddressHttpClientBuilder.appendClientFilter(StreamingHttpClientFilterFactory) on the last
argument of MultiAddressHttpClientBuilder.SingleAddressInitializer.initialize(String, Object, SingleAddressHttpClientBuilder).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.this@Deprecated public MultiAddressHttpClientBuilder<U,R> appendClientFilter(Predicate<StreamingHttpRequest> predicate, StreamingHttpClientFilterFactory factory)
initializer(SingleAddressInitializer) and
SingleAddressHttpClientBuilder.appendClientFilter(Predicate, StreamingHttpClientFilterFactory) on the
last argument of MultiAddressHttpClientBuilder.SingleAddressInitializer.initialize(String, Object, SingleAddressHttpClientBuilder).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.this@Deprecated public abstract MultiAddressHttpClientBuilder<U,R> appendClientFilter(MultiAddressHttpClientFilterFactory<U> factory)
initializer(SingleAddressInitializer) and
SingleAddressHttpClientBuilder.appendClientFilter(StreamingHttpClientFilterFactory)
on the last argument of
MultiAddressHttpClientBuilder.SingleAddressInitializer.initialize(String, Object, SingleAddressHttpClientBuilder).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.this@Deprecated public MultiAddressHttpClientBuilder<U,R> appendClientFilter(Predicate<StreamingHttpRequest> predicate, MultiAddressHttpClientFilterFactory<U> factory)
initializer(SingleAddressInitializer) and
SingleAddressHttpClientBuilder.appendClientFilter(Predicate, StreamingHttpClientFilterFactory)
on the last argument of
MultiAddressHttpClientBuilder.SingleAddressInitializer.initialize(String, Object, SingleAddressHttpClientBuilder).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.this@Deprecated public MultiAddressHttpClientBuilder<U,R> maxRedirects(int maxRedirects)
followRedirects(RedirectConfig) with RedirectConfigBuilder.maxRedirects(int).
Starting from version 0.42, redirects will be disabled by default and RedirectConfig will be required to
enable them.maxRedirects - A maximum number of redirects to follow. 0 disables redirects.this.public MultiAddressHttpClientBuilder<U,R> followRedirects(RedirectConfig config)
Note: For backward compatibility with 0.41.x versions redirects are enabled by default. Starting from version 0.42, users have to opt-in for redirects using this method. If you rely on redirects, always use this method.
config - RedirectConfig to configure redirection behavior. It can be used to tune what requests
should follow redirects and which parts of the original request (headers/payload body/trailers) should be
redirected to non-relative locations.this.RedirectConfigBuilderpublic HttpClientBuilder<U,R,SDE> retryServiceDiscoveryErrors(BiIntFunction<Throwable,? extends Completable> retryStrategy)
ServiceDiscoverer.retryStrategy - a retry strategy to retry errors emitted by ServiceDiscoverer.
Note, calling this method will unset the value provided via
retryServiceDiscoveryErrors(ServiceDiscoveryRetryStrategy) if it was called before.
this.RetryStrategiespublic 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