Class DelegatingSingleAddressHttpClientBuilder<U,R>
- Type Parameters:
U
- the type of address before resolution (unresolved address)R
- the type of address after resolution (resolved address)
- All Implemented Interfaces:
SingleAddressHttpClientBuilder<U,
R>
- Direct Known Subclasses:
DefaultHttpLoadBalancerProvider.LoadBalancerIgnoringBuilder
SingleAddressHttpClientBuilder
that delegates all methods to another
SingleAddressHttpClientBuilder
.-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance. -
Method Summary
Modifier and TypeMethodDescriptionallowDropResponseTrailers
(boolean allowDrop) Provide a hint if response trailers are allowed to be dropped.Appends the filter to the chain of filters used to decorate theHttpClient
created by this builder.appendClientFilter
(Predicate<StreamingHttpRequest> predicate, StreamingHttpClientFilterFactory factory) Appends the filter to the chain of filters used to decorate theHttpClient
created by this builder, for every request that passes the providedPredicate
.Appends the filter to the chain of filters used to decorate theConnectionFactory
used by this builder.Appends the filter to the chain of filters used to decorate theStreamingHttpConnection
created by this builder.appendConnectionFilter
(Predicate<StreamingHttpRequest> predicate, StreamingHttpConnectionFilterFactory factory) Appends the filter to the chain of filters used to decorate theStreamingHttpConnection
created by this builder, for every request that passes the providedPredicate
.bufferAllocator
(BufferAllocator allocator) build()
protected final SingleAddressHttpClientBuilder<U,
R> delegate()
Returns theSingleAddressHttpClientBuilder
delegate.enableWireLogging
(String loggerName, LogLevel logLevel, BooleanSupplier logUserData) Enables wire-logging for connections created by this builder.executionStrategy
(HttpExecutionStrategy strategy) Sets theHttpExecutionStrategy
to be used for client callbacks when executing client requests for all clients created from this builder.hostHeaderFallback
(boolean enable) Configures automatically settingHost
headers by inferring from the address.inferPeerHost
(boolean shouldInfer) Toggle inference of value to use instead ofClientSslConfig.peerHost()
from client's address when peer host is not specified.inferPeerPort
(boolean shouldInfer) Toggle inference of value to use instead ofClientSslConfig.peerPort()
from client's address when peer port is not specified (equals-1
).inferSniHostname
(boolean shouldInfer) Toggle SNI hostname inference from client's address if not explicitly specified viaSingleAddressHttpClientBuilder.sslConfig(ClientSslConfig)
.ioExecutor
(IoExecutor ioExecutor) loadBalancerFactory
(HttpLoadBalancerFactory<R> loadBalancerFactory) Sets aHttpLoadBalancerFactory
to createLoadBalancer
instances.protocols
(HttpProtocolConfig... protocols) Configurations of various HTTP protocol versions.proxyAddress
(U proxyAddress) Configures a proxy to serve as an intermediary for requests.proxyConfig
(ProxyConfig<U> proxyConfig) Configures a proxy to serve as an intermediary for requests.retryServiceDiscoveryErrors
(BiIntFunction<Throwable, ? extends Completable> retryStrategy) Sets a retry strategy to retry errors emitted byServiceDiscoverer
.serviceDiscoverer
(ServiceDiscoverer<U, R, ? extends ServiceDiscovererEvent<R>> serviceDiscoverer) Sets aServiceDiscoverer
to resolve addresses of remote servers to connect to.socketOption
(SocketOption<T> option, T value) Adds aSocketOption
for all connections created by this builder.sslConfig
(ClientSslConfig sslConfig) Set the SSL/TLS configuration.toString()
transportConfig
(TransportConfig transportConfig) Set the transport configuration.unresolvedAddressToHost
(Function<U, CharSequence> unresolvedAddressToHostFunction) Provides a means to convertSingleAddressHttpClientBuilder
unresolved address type into aCharSequence
.
-
Constructor Details
-
DelegatingSingleAddressHttpClientBuilder
Create a new instance.- Parameters:
delegate
-SingleAddressHttpClientBuilder
to which all methods are delegated.
-
-
Method Details
-
delegate
Returns theSingleAddressHttpClientBuilder
delegate.- Returns:
- Delegate
SingleAddressHttpClientBuilder
.
-
toString
-
proxyAddress
Description copied from interface:SingleAddressHttpClientBuilder
Configures a proxy to serve as an intermediary for requests.If the client talks to a proxy over http (not https,
ClientSslConfig
is NOT configured), it will rewrite the request-target to absolute-form, as specified by the RFC.For secure proxy tunnels (when
ClientSslConfig
is configured) the tunnel is always initialized using HTTP/1.1 CONNECT request. The actual protocol will be negotiated via ALPN extension of TLS protocol, taking into account HTTP protocols configured viaSingleAddressHttpClientBuilder.protocols(HttpProtocolConfig...)
method. In case of any error duringCONNECT
process,ProxyConnectException
orProxyConnectResponseException
will be thrown when a request attempt is made through the constructed client instance.- Specified by:
proxyAddress
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
proxyAddress
- Unresolved address of the proxy. When used with a builder created for a resolved address,proxyAddress
should also be already resolved – otherwise runtime exceptions may occur.- Returns:
this
.
-
proxyConfig
Description copied from interface:SingleAddressHttpClientBuilder
Configures a proxy to serve as an intermediary for requests.If the client talks to a proxy over http (not https,
ClientSslConfig
is NOT configured), it will rewrite the request-target to absolute-form, as specified by the RFC.For secure proxy tunnels (when
ClientSslConfig
is configured) the tunnel is always initialized using HTTP/1.1 CONNECT request. The actual protocol will be negotiated via ALPN extension of TLS protocol, taking into account HTTP protocols configured viaSingleAddressHttpClientBuilder.protocols(HttpProtocolConfig...)
method. In case of any error duringCONNECT
process,ProxyConnectException
orProxyConnectResponseException
will be thrown when a request attempt is made through the constructed client instance.- Specified by:
proxyConfig
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
proxyConfig
- Configuration for a proxy. When used with a builder created for a resolved address,ProxyConfig.address()
must also be already resolved – otherwise runtime exceptions will occur.- Returns:
this
.- See Also:
-
socketOption
Description copied from interface:SingleAddressHttpClientBuilder
Adds aSocketOption
for all connections created by this builder.- Specified by:
socketOption
in interfaceSingleAddressHttpClientBuilder<U,
R> - Type Parameters:
T
- the type of the value.- Parameters:
option
- the option to apply.value
- the value.- Returns:
this
.- See Also:
-
enableWireLogging
public SingleAddressHttpClientBuilder<U,R> enableWireLogging(String loggerName, LogLevel logLevel, BooleanSupplier logUserData) Description copied from interface:SingleAddressHttpClientBuilder
Enables wire-logging for connections created by this builder.- Specified by:
enableWireLogging
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
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 method is invoked for each data object allowing for dynamic behavior.- Returns:
this
.
-
protocols
Description copied from interface:SingleAddressHttpClientBuilder
Configurations of various HTTP protocol versions.Note: the order of specified protocols will reflect on priorities for ALPN in case the connections use TLS.
- Specified by:
protocols
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
protocols
-HttpProtocolConfig
for each protocol that should be supported.- Returns:
this
.
-
hostHeaderFallback
Description copied from interface:SingleAddressHttpClientBuilder
Configures automatically settingHost
headers by inferring from the address.When
false
is passed, this setting disables the default filter such that noHost
header will be manipulated.- Specified by:
hostHeaderFallback
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
enable
- Whether a default filter for inferring theHost
headers should be added.- Returns:
this
- See Also:
-
allowDropResponseTrailers
Description copied from interface:SingleAddressHttpClientBuilder
Provide a hint if response trailers are allowed to be dropped. This hint maybe ignored if the transport can otherwise infer that trailers should be preserved. For example, if the response headers contain Trailer then this hint maybe ignored.- Specified by:
allowDropResponseTrailers
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
allowDrop
-true
if response trailers are allowed to be dropped.- Returns:
this
-
appendConnectionFilter
public SingleAddressHttpClientBuilder<U,R> appendConnectionFilter(StreamingHttpConnectionFilterFactory factory) Description copied from interface:SingleAddressHttpClientBuilder
Appends the filter to the chain of filters used to decorate theStreamingHttpConnection
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.appendConnectionFilter(filter1).appendConnectionFilter(filter2).appendConnectionFilter(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
- Specified by:
appendConnectionFilter
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
factory
-StreamingHttpConnectionFilterFactory
to decorate aStreamingHttpConnection
for the purpose of filtering.- Returns:
this
-
appendConnectionFilter
public SingleAddressHttpClientBuilder<U,R> appendConnectionFilter(Predicate<StreamingHttpRequest> predicate, StreamingHttpConnectionFilterFactory factory) Description copied from interface:SingleAddressHttpClientBuilder
Appends the filter to the chain of filters used to decorate theStreamingHttpConnection
created by this builder, for every request that passes the providedPredicate
.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.appendConnectionFilter(filter1).appendConnectionFilter(filter2).appendConnectionFilter(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
When overriding this method, delegate to
super
as it uses internal utilities to provide a consistent execution flow.- Specified by:
appendConnectionFilter
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
predicate
- thePredicate
to test if the filter must be applied.factory
-StreamingHttpConnectionFilterFactory
to decorate aStreamingHttpConnection
for the purpose of filtering.- Returns:
this
-
ioExecutor
- Specified by:
ioExecutor
in interfaceSingleAddressHttpClientBuilder<U,
R>
-
executor
- Specified by:
executor
in interfaceSingleAddressHttpClientBuilder<U,
R>
-
executionStrategy
Description copied from interface:SingleAddressHttpClientBuilder
Sets theHttpExecutionStrategy
to be used for client callbacks when executing client requests for all clients created from this builder.Specifying an execution strategy affects the offloading used during execution of client requests:
- Unspecified or
HttpExecutionStrategies.defaultStrategy()
- Execution of client requests will use a safe (non-blocking) execution strategy appropriate for the
client API used and the filters added. Blocking is always safe as all potentially blocking paths are
offloaded. Each client API variant (async/blocking streaming/aggregate) requires a specific execution
strategy to avoid blocking the event-loop and filters added via
SingleAddressHttpClientBuilder.appendClientFilter(StreamingHttpClientFilterFactory)
,SingleAddressHttpClientBuilder.appendConnectionFilter(StreamingHttpConnectionFilterFactory)
, orSingleAddressHttpClientBuilder.appendConnectionFactoryFilter(ConnectionFactoryFilter)
, etc. may also require offloading. The execution strategy for execution of client requests will be computed based on the client API in use andHttpExecutionStrategyInfluencer.requiredOffloads()
of added the filters. HttpExecutionStrategies.offloadNone()
(or deprecatedHttpExecutionStrategies.offloadNever()
)- No offloading will be used during execution of client requests regardless of the client API used or the influence of added filters. Filters and asynchronous callbacks must not ever block during the execution of client requests.
- A custom execution strategy (
HttpExecutionStrategies.customStrategyBuilder()
) orHttpExecutionStrategies.offloadAll()
- The specified execution strategy will be used for executing client requests rather than the client API's default safe strategy. Like with the default strategy, the actual execution strategy used is computed from the provided strategy and the execution strategies required by added filters. Filters and asynchronous callbacks MAY only block during the offloaded portions of the client request execution.
- Specified by:
executionStrategy
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
strategy
-HttpExecutionStrategy
to use. If callbacks to the application code may block then those callbacks must request to be offloaded.- Returns:
this
.- See Also:
- Unspecified or
-
bufferAllocator
- Specified by:
bufferAllocator
in interfaceSingleAddressHttpClientBuilder<U,
R>
-
appendConnectionFactoryFilter
public SingleAddressHttpClientBuilder<U,R> appendConnectionFactoryFilter(ConnectionFactoryFilter<R, FilterableStreamingHttpConnection> factory) Description copied from interface:SingleAddressHttpClientBuilder
Appends the filter to the chain of filters used to decorate theConnectionFactory
used by this builder.Filtering allows you to wrap a
ConnectionFactory
and modify behavior ofConnectionFactory.newConnection(Object, ContextMap, 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 .appendConnectionFactoryFilter(filter1) .appendConnectionFactoryFilter(filter2) .appendConnectionFactoryFilter(filter3)
CallingConnectionFactory
wrapped by this filter chain, the order of invocation of these filters will be:filter1 ⇒ filter2 ⇒ filter3 ⇒ original connection factory
- Specified by:
appendConnectionFactoryFilter
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
factory
-ConnectionFactoryFilter
to use.- Returns:
this
-
appendClientFilter
public SingleAddressHttpClientBuilder<U,R> appendClientFilter(StreamingHttpClientFilterFactory factory) Description copied from interface:SingleAddressHttpClientBuilder
Appends the filter to the chain of filters used to decorate theHttpClient
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.appendClientFilter(filter1).appendClientFilter(filter2).appendClientFilter(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
- Specified by:
appendClientFilter
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
factory
-StreamingHttpClientFilterFactory
to decorate aHttpClient
for the purpose of filtering.- Returns:
this
-
appendClientFilter
public SingleAddressHttpClientBuilder<U,R> appendClientFilter(Predicate<StreamingHttpRequest> predicate, StreamingHttpClientFilterFactory factory) Description copied from interface:SingleAddressHttpClientBuilder
Appends the filter to the chain of filters used to decorate theHttpClient
created by this builder, for every request that passes the providedPredicate
.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.appendClientFilter(filter1).appendClientFilter(filter2).appendClientFilter(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
- Specified by:
appendClientFilter
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
predicate
- thePredicate
to test if the filter must be applied.factory
-StreamingHttpClientFilterFactory
to decorate aHttpClient
for the purpose of filtering.- Returns:
this
-
unresolvedAddressToHost
public SingleAddressHttpClientBuilder<U,R> unresolvedAddressToHost(Function<U, CharSequence> unresolvedAddressToHostFunction) Description copied from interface:SingleAddressHttpClientBuilder
Provides a means to convertSingleAddressHttpClientBuilder
unresolved address type into aCharSequence
. An example of where this maybe used is to convert theSingleAddressHttpClientBuilder
to a default host header. It may also be used in the event of proxying.- Specified by:
unresolvedAddressToHost
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
unresolvedAddressToHostFunction
- invoked to convert theSingleAddressHttpClientBuilder
unresolved address type into aCharSequence
suitable for use in Host Header format.- Returns:
this
-
serviceDiscoverer
public SingleAddressHttpClientBuilder<U,R> serviceDiscoverer(ServiceDiscoverer<U, R, ? extends ServiceDiscovererEvent<R>> serviceDiscoverer) Description copied from interface:SingleAddressHttpClientBuilder
Sets aServiceDiscoverer
to resolve addresses of remote servers to connect to.- Specified by:
serviceDiscoverer
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
serviceDiscoverer
- TheServiceDiscoverer
to resolve addresses of remote servers to connect to. Lifecycle of the providedServiceDiscoverer
is managed externally and it should beclosed
after all builtStreamingHttpClient
s will be closed and thisServiceDiscoverer
is no longer needed.- Returns:
this
.
-
retryServiceDiscoveryErrors
public SingleAddressHttpClientBuilder<U,R> retryServiceDiscoveryErrors(BiIntFunction<Throwable, ? extends Completable> retryStrategy) Description copied from interface:SingleAddressHttpClientBuilder
Sets a retry strategy to retry errors emitted byServiceDiscoverer
.- Specified by:
retryServiceDiscoveryErrors
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
retryStrategy
- a retry strategy to retry errors emitted byServiceDiscoverer
.- Returns:
this
.- See Also:
-
loadBalancerFactory
public SingleAddressHttpClientBuilder<U,R> loadBalancerFactory(HttpLoadBalancerFactory<R> loadBalancerFactory) Description copied from interface:SingleAddressHttpClientBuilder
Sets aHttpLoadBalancerFactory
to createLoadBalancer
instances.- Specified by:
loadBalancerFactory
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
loadBalancerFactory
-HttpLoadBalancerFactory
to createLoadBalancer
instances.- Returns:
this
.
-
sslConfig
Description copied from interface:SingleAddressHttpClientBuilder
Set the SSL/TLS configuration.- Specified by:
sslConfig
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
sslConfig
- The configuration to use.- Returns:
this
.- See Also:
-
inferPeerHost
Description copied from interface:SingleAddressHttpClientBuilder
Toggle inference of value to use instead ofClientSslConfig.peerHost()
from client's address when peer host is not specified. By default, inference is enabled.- Specified by:
inferPeerHost
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
shouldInfer
- value indicating whether inference is on (true
) or off (false
).- Returns:
this
-
inferPeerPort
Description copied from interface:SingleAddressHttpClientBuilder
Toggle inference of value to use instead ofClientSslConfig.peerPort()
from client's address when peer port is not specified (equals-1
). By default, inference is enabled.- Specified by:
inferPeerPort
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
shouldInfer
- value indicating whether inference is on (true
) or off (false
).- Returns:
this
-
inferSniHostname
Description copied from interface:SingleAddressHttpClientBuilder
Toggle SNI hostname inference from client's address if not explicitly specified viaSingleAddressHttpClientBuilder.sslConfig(ClientSslConfig)
. By default, inference is enabled.- Specified by:
inferSniHostname
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
shouldInfer
- value indicating whether inference is on (true
) or off (false
).- Returns:
this
-
transportConfig
Description copied from interface:SingleAddressHttpClientBuilder
Set the transport configuration.- Specified by:
transportConfig
in interfaceSingleAddressHttpClientBuilder<U,
R> - Parameters:
transportConfig
-TransportConfig
to use- Returns:
this
- See Also:
-
build
-
buildStreaming
-
buildBlocking
-
buildBlockingStreaming
-