public class ReactorClientHttpConnector extends Object implements ClientHttpConnector
ClientHttpConnector
.HttpClient
Constructor and Description |
---|
ReactorClientHttpConnector()
Default constructor.
|
ReactorClientHttpConnector(reactor.netty.http.client.HttpClient httpClient)
Constructor with a pre-configured
HttpClient instance. |
ReactorClientHttpConnector(ReactorResourceFactory factory,
Function<reactor.netty.http.client.HttpClient,reactor.netty.http.client.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 |
---|---|
reactor.core.publisher.Mono<ClientHttpResponse> |
connect(HttpMethod method,
URI uri,
Function<? super ClientHttpRequest,reactor.core.publisher.Mono<Void>> 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. |
public ReactorClientHttpConnector()
HttpClient
via:
HttpClient.create().compress()
public ReactorClientHttpConnector(ReactorResourceFactory factory, Function<reactor.netty.http.client.HttpClient,reactor.netty.http.client.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
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(reactor.netty.http.client.HttpClient httpClient)
HttpClient
instance.httpClient
- the client to usepublic reactor.core.publisher.Mono<ClientHttpResponse> connect(HttpMethod method, URI uri, Function<? super ClientHttpRequest,reactor.core.publisher.Mono<Void>> 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(org.reactivestreams.Publisher<? extends org.springframework.core.io.buffer.DataBuffer>)
or ReactiveHttpOutputMessage.setComplete()
.ClientHttpResponse