Interface MultiAddressHttpClientBuilder<U,R>
- Type Parameters:
U- the type of address before resolution (unresolved address)R- the type of address after resolution (resolved address)
- All Known Implementing Classes:
DelegatingMultiAddressHttpClientBuilder
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.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceInitializes theSingleAddressHttpClientBuilderfor each new client. -
Method Summary
Modifier and TypeMethodDescriptiondefault MultiAddressHttpClientBuilder<U,R> Appends the filter to the chain of filters used to decorate theHttpClientcreated by this builder.default MultiAddressHttpClientBuilder<U,R> appendClientFilter(Predicate<StreamingHttpRequest> predicate, StreamingHttpClientFilterFactory factory) Appends the filter to the chain of filters used to decorate theHttpClientcreated by this builder, for every request that passes the providedPredicate.bufferAllocator(BufferAllocator allocator) default HttpClientbuild()Builds a newHttpClient.default BlockingHttpClientCreates a newBlockingHttpClient.default BlockingStreamingHttpClientCreates a newBlockingStreamingHttpClient.Builds a newStreamingHttpClient.default MultiAddressHttpClientBuilder<U,R> defaultHttpPort(int port) Configures the default port for the HTTP scheme if not explicitly provided as part of theHttpRequestMetaData.requestTarget().default MultiAddressHttpClientBuilder<U,R> defaultHttpsPort(int port) Configures the default port for the HTTPS scheme if not explicitly provided as part of theHttpRequestMetaData.requestTarget().executionStrategy(HttpExecutionStrategy strategy) Sets theHttpExecutionStrategyto be used for client callbacks when executing client requests for all clients created from this builder.followRedirects(RedirectConfig config) Configures redirection behavior.default MultiAddressHttpClientBuilder<U,R> headersFactory(HttpHeadersFactory headersFactory) Sets theHttpHeadersFactoryto be used for creatingHttpHeadersfor new requests.initializer(MultiAddressHttpClientBuilder.SingleAddressInitializer<U, R> initializer) Set a function which can customize options for eachStreamingHttpClientthat is built.ioExecutor(IoExecutor ioExecutor)
-
Method Details
-
ioExecutor
-
executor
-
executionStrategy
Sets theHttpExecutionStrategyto be used for client callbacks when executing client requests for all clients created from this builder.Provides the base execution strategy for all clients created from this builder and the default strategy for the
SingleAddressHttpClientBuilderused to construct client instances. Theinitializer(SingleAddressInitializer)may be used for some customization of the execution strategy for a specific single address client instance, but may not reduce the offloading to be performed. Specifically, the initializer may introduce additional offloading viaSingleAddressHttpClientBuilder.executionStrategy(HttpExecutionStrategy)and may add filters which influence the computed execution strategy.Specifying an execution strategy will affect the offloading used during the execution of client requests:
- Unspecified or
HttpExecutionStrategies.defaultStrategy() - The resulting client instances will use the default safe strategy for each API variant and
SingleAddressHttpClientBuilderinstances generated will also have default strategy. HttpExecutionStrategies.offloadNone()(or deprecatedHttpExecutionStrategies.offloadNever())SingleAddressHttpClientBuilderinstances created by the client will have a strategy ofHttpExecutionStrategies.offloadNone().HttpExecutionStrategies.offloadNone()execution strategy requires that filters and asynchronous callbacks must not ever block during the execution of client requests. Aninitializermay override to add offloads usingSingleAddressHttpClientBuilder.executionStrategy(HttpExecutionStrategy).- A custom execution strategy (
HttpExecutionStrategies.customStrategyBuilder()) orHttpExecutionStrategies.offloadAll() SingleAddressHttpClientBuilderinstances created by the client will start with the provided strategy and may add additional offloading as required by added filters.
- Parameters:
strategy-HttpExecutionStrategyto use. If callbacks to the application code may block then those callbacks must request to be offloaded.- Returns:
this.- See Also:
- Unspecified or
-
bufferAllocator
-
headersFactory
Sets theHttpHeadersFactoryto be used for creatingHttpHeadersfor new requests.- Parameters:
headersFactory-HttpHeadersFactoryto be used for creatingHttpHeadersfor new requests- Returns:
this
-
initializer
MultiAddressHttpClientBuilder<U,R> initializer(MultiAddressHttpClientBuilder.SingleAddressInitializer<U, R> initializer) Set a function which can customize options for eachStreamingHttpClientthat is built.- Parameters:
initializer- Initializes theSingleAddressHttpClientBuilderused to build newStreamingHttpClients. SeeexecutionStrategy(HttpExecutionStrategy)for discussion of restrictions on the use ofSingleAddressHttpClientBuilder.executionStrategy(HttpExecutionStrategy)within an initializer.- Returns:
this
-
followRedirects
Configures redirection behavior.- Parameters:
config-RedirectConfigto 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. Usenullto disable redirects.Note that this filters location is last, or as if it had been appended right before building the client. If that is not the desired position you can disable redirects and use
appendClientFilter(StreamingHttpClientFilterFactory)to place theRedirectingHttpRequesterFilterin the position of your choice.- Returns:
this.- See Also:
-
defaultHttpPort
Configures the default port for the HTTP scheme if not explicitly provided as part of theHttpRequestMetaData.requestTarget().- Parameters:
port- the port that should be used if not explicitly provided for HTTP requests.- Returns:
this.
-
defaultHttpsPort
Configures the default port for the HTTPS scheme if not explicitly provided as part of theHttpRequestMetaData.requestTarget().- Parameters:
port- the port that should be used if not explicitly provided for HTTPS requests.- Returns:
this.
-
appendClientFilter
default MultiAddressHttpClientBuilder<U,R> appendClientFilter(StreamingHttpClientFilterFactory factory) Appends the filter to the chain of filters used to decorate theHttpClientcreated 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 but will always be before any filters applied to the underlying single address clients. 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- Parameters:
factory-StreamingHttpClientFilterFactoryto decorate aHttpClientfor the purpose of filtering.- Returns:
this- See Also:
-
appendClientFilter
default MultiAddressHttpClientBuilder<U,R> appendClientFilter(Predicate<StreamingHttpRequest> predicate, StreamingHttpClientFilterFactory factory) Appends the filter to the chain of filters used to decorate theHttpClientcreated 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 but will always be before any filters applied to the underlying single address clients. 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- Parameters:
predicate- thePredicateto test if the filter must be applied.factory-StreamingHttpClientFilterFactoryto decorate aHttpClientfor the purpose of filtering.- Returns:
this- See Also:
-
buildStreaming
StreamingHttpClient buildStreaming()Builds a newStreamingHttpClient.- Returns:
- A new
StreamingHttpClient - Throws:
IllegalArgumentException- for incomplete or illegal configurationsIllegalStateException- for unsupported configuration combinations
-
build
Builds a newHttpClient.- Returns:
- A new
HttpClient
-
buildBlockingStreaming
Creates a newBlockingStreamingHttpClient.- Returns:
BlockingStreamingHttpClient
-
buildBlocking
Creates a newBlockingHttpClient.- Returns:
BlockingHttpClient
-