public class ReactorClientHttpConnector extends java.lang.Object implements ClientHttpConnector
ClientHttpConnector
.reactor.netty.http.client.HttpClient
Modifier and Type | Field and Description |
---|---|
private static java.util.function.Function<HttpClient,HttpClient> |
defaultInitializer |
private HttpClient |
httpClient |
Constructor and Description |
---|
ReactorClientHttpConnector()
Default constructor.
|
ReactorClientHttpConnector(HttpClient httpClient)
Constructor with a pre-configured
HttpClient instance. |
ReactorClientHttpConnector(ReactorResourceFactory factory,
java.util.function.Function<HttpClient,HttpClient> mapper)
Constructor with externally managed Reactor Netty resources, including
LoopResources for event loop threads, and ConnectionProvider
for the connection pool. |
Modifier and Type | Method and Description |
---|---|
private ReactorClientHttpRequest |
adaptRequest(HttpMethod method,
java.net.URI uri,
HttpClientRequest request,
NettyOutbound nettyOutbound) |
private ClientHttpResponse |
adaptResponse(HttpClientResponse response,
NettyInbound nettyInbound,
ByteBufAllocator allocator) |
<any> |
connect(HttpMethod method,
java.net.URI uri,
java.util.function.Function<? super ClientHttpRequest,<any>> requestCallback)
Connect to the origin server using the given
HttpMethod and
URI and apply the given requestCallback when the HTTP
request of the underlying API can be initialized and written to. |
private static HttpClient |
initHttpClient(ReactorResourceFactory resourceFactory) |
private static final java.util.function.Function<HttpClient,HttpClient> defaultInitializer
private final HttpClient httpClient
public ReactorClientHttpConnector()
HttpClient
via:
HttpClient.create().compress()
public ReactorClientHttpConnector(ReactorResourceFactory factory, java.util.function.Function<HttpClient,HttpClient> mapper)
LoopResources
for event loop threads, and ConnectionProvider
for the connection pool.
This constructor should be used only when you don't want the client
to participate in the Reactor Netty global resources. By default the
client participates in the Reactor Netty global resources held in
reactor.netty.http.HttpResources
, which is recommended since
fixed, shared resources are favored for event loop concurrency. However,
consider declaring a ReactorResourceFactory
bean with
globalResources=true
in order to ensure the Reactor Netty global
resources are shut down when the Spring ApplicationContext is closed.
factory
- the resource factory to obtain the resources frommapper
- a mapper for further initialization of the created clientpublic ReactorClientHttpConnector(HttpClient httpClient)
HttpClient
instance.httpClient
- the client to useprivate static HttpClient initHttpClient(ReactorResourceFactory resourceFactory)
public <any> connect(HttpMethod method, java.net.URI uri, java.util.function.Function<? super ClientHttpRequest,<any>> requestCallback)
ClientHttpConnector
HttpMethod
and
URI
and apply the given requestCallback
when the HTTP
request of the underlying API can be initialized and written to.connect
in interface ClientHttpConnector
method
- the HTTP request methoduri
- the HTTP request URIrequestCallback
- a function that prepares and writes to the request,
returning a publisher that signals when it's done writing.
Implementations can return a Mono<Void>
by calling
ReactiveHttpOutputMessage.writeWith(<any>)
or ReactiveHttpOutputMessage.setComplete()
.ClientHttpResponse
private ReactorClientHttpRequest adaptRequest(HttpMethod method, java.net.URI uri, HttpClientRequest request, NettyOutbound nettyOutbound)
private ClientHttpResponse adaptResponse(HttpClientResponse response, NettyInbound nettyInbound, ByteBufAllocator allocator)