U - the type of address before resolution (unresolved address)R - the type of address after resolution (resolved address)public abstract class PartitionedHttpClientBuilder<U,R>
extends Object
StreamingHttpClient instances which call the server associated with a partition
selected from a set of PartitionedServiceDiscovererEvents resolved from a single unresolved address.
Partition selection uses a function to infer PartitionAttributes from the HttpRequestMetaData.
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 |
|---|
PartitionedHttpClientBuilder() |
| Modifier and Type | Method and Description |
|---|---|
abstract PartitionedHttpClientBuilder<U,R> |
appendClientBuilderFilter(PartitionHttpClientBuilderConfigurator<U,R> clientFilterFunction)
Sets a function that allows customizing the
SingleAddressHttpClientBuilder used to create the client for
a given partition based on its PartitionAttributes. |
PartitionedHttpClientBuilder<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 PartitionedHttpClientBuilder<U,R> |
appendClientFilter(StreamingHttpClientFilterFactory function)
Appends the filter to the chain of filters used to decorate the
HttpClient created by this
builder. |
abstract PartitionedHttpClientBuilder<U,R> |
appendConnectionFactoryFilter(ConnectionFactoryFilter<R,FilterableStreamingHttpConnection> factory)
Appends the filter to the chain of filters used to decorate the
ConnectionFactory used by this
builder. |
PartitionedHttpClientBuilder<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 PartitionedHttpClientBuilder<U,R> |
appendConnectionFilter(StreamingHttpConnectionFilterFactory factory)
Appends the filter to the chain of filters used to decorate the
StreamingHttpConnection created by this
builder. |
abstract PartitionedHttpClientBuilder<U,R> |
autoRetryStrategy(AutoRetryStrategyProvider autoRetryStrategyProvider)
Updates the automatic retry strategy for the clients generated by this builder.
|
abstract PartitionedHttpClientBuilder<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 PartitionedHttpClientBuilder<U,R> |
disableHostHeaderFallback()
Disables automatically setting
Host headers by inferring from the address or HttpMetaData. |
abstract PartitionedHttpClientBuilder<U,R> |
enableWireLogging(String loggerName)
Deprecated.
|
abstract PartitionedHttpClientBuilder<U,R> |
enableWireLogging(String loggerName,
LogLevel logLevel,
BooleanSupplier logUserData)
Enables wire-logging for connections created by this builder.
|
abstract PartitionedHttpClientBuilder<U,R> |
executionStrategy(HttpExecutionStrategy strategy)
Sets the
HttpExecutionStrategy for all connections created from this builder. |
abstract PartitionedHttpClientBuilder<U,R> |
ioExecutor(IoExecutor ioExecutor)
Sets the
IoExecutor for all connections created from this builder. |
abstract PartitionedHttpClientBuilder<U,R> |
loadBalancerFactory(HttpLoadBalancerFactory<R> loadBalancerFactory)
Sets a
HttpLoadBalancerFactory to create LoadBalancer instances. |
abstract PartitionedHttpClientBuilder<U,R> |
partitionMapFactory(PartitionMapFactory partitionMapFactory)
Sets
PartitionMapFactory to use by all StreamingHttpClients created by this builder. |
abstract PartitionedHttpClientBuilder<U,R> |
protocols(HttpProtocolConfig... protocols)
Configurations of various HTTP protocol versions.
|
abstract PartitionedHttpClientBuilder<U,R> |
retryServiceDiscoveryErrors(ServiceDiscoveryRetryStrategy<R,PartitionedServiceDiscovererEvent<R>> retryStrategy)
Sets a retry strategy to retry errors emitted by
ServiceDiscoverer. |
abstract PartitionedHttpClientSecurityConfigurator<U,R> |
secure()
Initiates security configuration for this client.
|
abstract PartitionedHttpClientBuilder<U,R> |
serviceDiscoverer(ServiceDiscoverer<U,R,PartitionedServiceDiscovererEvent<R>> serviceDiscoverer)
Sets a
ServiceDiscoverer to resolve addresses of remote servers to connect to. |
abstract PartitionedHttpClientBuilder<U,R> |
serviceDiscoveryMaxQueueSize(int serviceDiscoveryMaxQueueSize)
Sets the maximum amount of
ServiceDiscovererEvent objects that will be queued for each partition. |
abstract <T> PartitionedHttpClientBuilder<U,R> |
socketOption(SocketOption<T> option,
T value)
Adds a
SocketOption for all connections created by this builder. |
abstract PartitionedHttpClientBuilder<U,R> |
unresolvedAddressToHost(Function<U,CharSequence> unresolvedAddressToHostFunction)
Provides a means to convert
U unresolved address type into a CharSequence. |
public abstract PartitionedHttpClientBuilder<U,R> ioExecutor(IoExecutor ioExecutor)
IoExecutor for all connections created from this builder.ioExecutor - IoExecutor to use.this.public abstract PartitionedHttpClientBuilder<U,R> executionStrategy(HttpExecutionStrategy strategy)
HttpExecutionStrategy for all connections created from this builder.strategy - HttpExecutionStrategy to use.this.public abstract PartitionedHttpClientBuilder<U,R> bufferAllocator(BufferAllocator allocator)
BufferAllocator for all connections created from this builder.allocator - BufferAllocator to use.this.public abstract <T> PartitionedHttpClientBuilder<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,
ServiceTalkSocketOptions@Deprecated public abstract PartitionedHttpClientBuilder<U,R> enableWireLogging(String loggerName)
loggerName - The name of the logger to log wire events.this.public abstract PartitionedHttpClientBuilder<U,R> enableWireLogging(String loggerName, LogLevel logLevel, BooleanSupplier logUserData)
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.public abstract PartitionedHttpClientBuilder<U,R> 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 PartitionedHttpClientBuilder<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 PartitionedHttpClientBuilder<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 PartitionedHttpClientBuilder<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, 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.thispublic abstract PartitionedHttpClientBuilder<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.
thisMultiAddressHttpClientBuilder.unresolvedAddressToHost(Function)public abstract PartitionedHttpClientBuilder<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 PartitionedHttpClientBuilder<U,R> serviceDiscoverer(ServiceDiscoverer<U,R,PartitionedServiceDiscovererEvent<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 PartitionedHttpClientBuilder<U,R> retryServiceDiscoveryErrors(ServiceDiscoveryRetryStrategy<R,PartitionedServiceDiscovererEvent<R>> retryStrategy)
ServiceDiscoverer.retryStrategy - a retry strategy to retry errors emitted by ServiceDiscoverer.this.public abstract PartitionedHttpClientBuilder<U,R> loadBalancerFactory(HttpLoadBalancerFactory<R> loadBalancerFactory)
HttpLoadBalancerFactory to create LoadBalancer instances.loadBalancerFactory - HttpLoadBalancerFactory to create LoadBalancer instances.this.public abstract PartitionedHttpClientBuilder<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 PartitionedHttpClientBuilder<U,R> appendClientFilter(StreamingHttpClientFilterFactory function)
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
function - StreamingHttpClientFilterFactory to decorate a HttpClient for the purpose of
filtering.thispublic PartitionedHttpClientBuilder<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 PartitionedHttpClientSecurityConfigurator<U,R> secure()
PartitionedHttpClientSecurityConfigurator.commit() on the returned
PartitionedHttpClientSecurityConfigurator will commit the configuration.PartitionHttpClientBuilderConfigurator to configure security for this client. It is
mandatory to call commit after all configuration is
done.public abstract PartitionedHttpClientBuilder<U,R> serviceDiscoveryMaxQueueSize(int serviceDiscoveryMaxQueueSize)
ServiceDiscovererEvent objects that will be queued for each partition.
It is assumed that the PublisherSource.Subscribers will process events in a timely manner (typically synchronously)
so this typically doesn't need to be very large.
serviceDiscoveryMaxQueueSize - the maximum amount of ServiceDiscovererEvent objects that will be
queued for each partition.this.public abstract PartitionedHttpClientBuilder<U,R> partitionMapFactory(PartitionMapFactory partitionMapFactory)
PartitionMapFactory to use by all StreamingHttpClients created by this builder.partitionMapFactory - PartitionMapFactory to use.this.public abstract PartitionedHttpClientBuilder<U,R> appendClientBuilderFilter(PartitionHttpClientBuilderConfigurator<U,R> clientFilterFunction)
SingleAddressHttpClientBuilder used to create the client for
a given partition based on its PartitionAttributes.clientFilterFunction - BiFunction used to customize the SingleAddressHttpClientBuilder
before creating the client for the partitionthispublic 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