U
- the type of address before resolution (unresolved address)R
- the type of address after resolution (resolved address)public abstract class SingleAddressHttpClientBuilder<U,R>
extends java.lang.Object
StreamingHttpClient
instances which call a single server based on the provided unresolved
address.
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 |
---|
SingleAddressHttpClientBuilder() |
Modifier and Type | Method and Description |
---|---|
SingleAddressHttpClientBuilder<U,R> |
appendClientFilter(java.util.function.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 SingleAddressHttpClientBuilder<U,R> |
appendClientFilter(StreamingHttpClientFilterFactory factory)
Appends the filter to the chain of filters used to decorate the
HttpClient created by this
builder. |
abstract SingleAddressHttpClientBuilder<U,R> |
appendConnectionFactoryFilter(ConnectionFactoryFilter<R,FilterableStreamingHttpConnection> factory)
Appends the filter to the chain of filters used to decorate the
ConnectionFactory used by this
builder. |
SingleAddressHttpClientBuilder<U,R> |
appendConnectionFilter(java.util.function.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 SingleAddressHttpClientBuilder<U,R> |
appendConnectionFilter(StreamingHttpConnectionFilterFactory factory)
Appends the filter to the chain of filters used to decorate the
StreamingHttpConnection created by this
builder. |
abstract SingleAddressHttpClientBuilder<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 SingleAddressHttpClientBuilder<U,R> |
disableHostHeaderFallback()
Disables automatically setting
Host headers by inferring from the address or HttpMetaData . |
abstract SingleAddressHttpClientBuilder<U,R> |
disableWaitForLoadBalancer()
Disables automatically delaying
StreamingHttpRequest s until the LoadBalancer is ready. |
abstract SingleAddressHttpClientBuilder<U,R> |
enableWireLogging(java.lang.String loggerName)
Enables wire-logging for connections created by this builder.
|
abstract SingleAddressHttpClientBuilder<U,R> |
executionStrategy(HttpExecutionStrategy strategy)
Sets the
HttpExecutionStrategy for all connections created from this builder. |
abstract SingleAddressHttpClientBuilder<U,R> |
ioExecutor(IoExecutor ioExecutor)
Sets the
IoExecutor for all connections created from this builder. |
abstract SingleAddressHttpClientBuilder<U,R> |
loadBalancerFactory(LoadBalancerFactory<R,FilterableStreamingHttpLoadBalancedConnection> loadBalancerFactory,
java.util.function.Function<FilterableStreamingHttpConnection,FilterableStreamingHttpLoadBalancedConnection> protocolBinder)
Sets a
LoadBalancerFactory to generate LoadBalancer objects. |
abstract SingleAddressHttpClientBuilder<U,R> |
protocols(HttpProtocolConfig... protocols)
Configurations of various HTTP protocol versions.
|
abstract SingleAddressHttpClientSecurityConfigurator<U,R> |
secure()
Initiates security configuration for this client.
|
abstract SingleAddressHttpClientBuilder<U,R> |
serviceDiscoverer(ServiceDiscoverer<U,R,? extends ServiceDiscovererEvent<R>> serviceDiscoverer)
Sets a
ServiceDiscoverer to resolve addresses of remote servers to connect to. |
abstract <T> SingleAddressHttpClientBuilder<U,R> |
socketOption(java.net.SocketOption<T> option,
T value)
Adds a
SocketOption for all connections created by this builder. |
abstract SingleAddressHttpClientBuilder<U,R> |
unresolvedAddressToHost(java.util.function.Function<U,java.lang.CharSequence> unresolvedAddressToHostFunction)
Provides a means to convert
U unresolved address type into a CharSequence . |
public abstract SingleAddressHttpClientBuilder<U,R> ioExecutor(IoExecutor ioExecutor)
IoExecutor
for all connections created from this builder.ioExecutor
- IoExecutor
to use.this
.public abstract SingleAddressHttpClientBuilder<U,R> executionStrategy(HttpExecutionStrategy strategy)
HttpExecutionStrategy
for all connections created from this builder.strategy
- HttpExecutionStrategy
to use.this
.public abstract SingleAddressHttpClientBuilder<U,R> bufferAllocator(BufferAllocator allocator)
BufferAllocator
for all connections created from this builder.allocator
- BufferAllocator
to use.this
.public abstract <T> SingleAddressHttpClientBuilder<U,R> socketOption(java.net.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
.public abstract SingleAddressHttpClientBuilder<U,R> enableWireLogging(java.lang.String loggerName)
All wire events will be logged at TRACE
level.
loggerName
- The name of the logger to log wire events.this
.public abstract SingleAddressHttpClientBuilder<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 SingleAddressHttpClientBuilder<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.this
public SingleAddressHttpClientBuilder<U,R> appendConnectionFilter(java.util.function.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.this
public abstract SingleAddressHttpClientBuilder<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.this
public abstract SingleAddressHttpClientBuilder<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.
this
MultiAddressHttpClientBuilder.unresolvedAddressToHost(Function)
public abstract SingleAddressHttpClientBuilder<U,R> disableWaitForLoadBalancer()
StreamingHttpRequest
s until the LoadBalancer
is ready.this
public abstract SingleAddressHttpClientBuilder<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 StreamingHttpClient
s will be closed and
this ServiceDiscoverer
is no longer needed.this
.public abstract SingleAddressHttpClientBuilder<U,R> loadBalancerFactory(LoadBalancerFactory<R,FilterableStreamingHttpLoadBalancedConnection> loadBalancerFactory, java.util.function.Function<FilterableStreamingHttpConnection,FilterableStreamingHttpLoadBalancedConnection> protocolBinder)
LoadBalancerFactory
to generate LoadBalancer
objects.loadBalancerFactory
- The LoadBalancerFactory
which generates LoadBalancer
objects.protocolBinder
- The Function
that bridges the HTTP protocol to the FilterableStreamingHttpLoadBalancedConnection
which exposes a ScoreSupplier.score()
function
which may inform the LoadBalancer
created from the provided loadBalancerFactory
while making
connection selection decisions.this
.public abstract SingleAddressHttpClientBuilder<U,R> unresolvedAddressToHost(java.util.function.Function<U,java.lang.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.this
public abstract SingleAddressHttpClientBuilder<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.this
public SingleAddressHttpClientBuilder<U,R> appendClientFilter(java.util.function.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.this
public abstract SingleAddressHttpClientSecurityConfigurator<U,R> secure()
SingleAddressHttpClientSecurityConfigurator.commit()
on the returned
SingleAddressHttpClientSecurityConfigurator
will commit the configuration.SingleAddressHttpClientSecurityConfigurator
to configure security for this client. It is
mandatory to call commit
after all configuration is
done.public abstract StreamingHttpClient buildStreaming()
StreamingHttpClient
, using a default ExecutionContext
.StreamingHttpClient
public final HttpClient build()
HttpClient
, using a default ExecutionContext
.HttpClient
public final BlockingStreamingHttpClient buildBlockingStreaming()
BlockingStreamingHttpClient
, using a default ExecutionContext
.BlockingStreamingHttpClient
public final BlockingHttpClient buildBlocking()
BlockingHttpClient
, using a default ExecutionContext
.BlockingHttpClient