类 ReactorClientHttpConnector
- java.lang.Object
- org.springframework.http.client.reactive.ReactorClientHttpConnector
- 所有已实现的接口:
ClientHttpConnector
public class ReactorClientHttpConnector extends Object implements ClientHttpConnector
Reactor-Netty implementation ofClientHttpConnector
.- 从以下版本开始:
- 5.0
- 作者:
- Brian Clozel, Rossen Stoyanchev
- 另请参阅:
HttpClient
构造器概要
构造器 构造器 说明 ReactorClientHttpConnector()
Default constructor.ReactorClientHttpConnector(ReactorResourceFactory factory, Function<reactor.netty.http.client.HttpClient,reactor.netty.http.client.HttpClient> mapper)
Constructor with externally managed Reactor Netty resources, includingLoopResources
for event loop threads, andConnectionProvider
for the connection pool.ReactorClientHttpConnector(reactor.netty.http.client.HttpClient httpClient)
Constructor with a pre-configuredHttpClient
instance.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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 givenHttpMethod
andURI
and apply the givenrequestCallback
when the HTTP request of the underlying API can be initialized and written to.
构造器详细资料
ReactorClientHttpConnector
public ReactorClientHttpConnector()
Default constructor. InitializesHttpClient
via:HttpClient.create().compress()
ReactorClientHttpConnector
public ReactorClientHttpConnector(ReactorResourceFactory factory, Function<reactor.netty.http.client.HttpClient,reactor.netty.http.client.HttpClient> mapper)
Constructor with externally managed Reactor Netty resources, includingLoopResources
for event loop threads, andConnectionProvider
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 aReactorResourceFactory
bean withglobalResources=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 client- 从以下版本开始:
- 5.1
ReactorClientHttpConnector
public ReactorClientHttpConnector(reactor.netty.http.client.HttpClient httpClient)
Constructor with a pre-configuredHttpClient
instance.- 参数:
httpClient
- the client to use- 从以下版本开始:
- 5.1
方法详细资料
connect
public reactor.core.publisher.Mono<ClientHttpResponse> connect(HttpMethod method, URI uri, Function<? super ClientHttpRequest,reactor.core.publisher.Mono<Void>> requestCallback)
从接口复制的说明:ClientHttpConnector
Connect to the origin server using the givenHttpMethod
andURI
and apply the givenrequestCallback
when the HTTP request of the underlying API can be initialized and written to.- 指定者:
connect
在接口中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 aMono<Void>
by callingReactiveHttpOutputMessage.writeWith(org.reactivestreams.Publisher<? extends org.springframework.core.io.buffer.DataBuffer>)
orReactiveHttpOutputMessage.setComplete()
.- 返回:
- publisher for the
ClientHttpResponse