Package reactor.netty.transport
Class ClientTransport<T extends ClientTransport<T,CONF>,CONF extends ClientTransportConfig<CONF>>
java.lang.Object
reactor.netty.transport.Transport<T,CONF>
reactor.netty.transport.ClientTransport<T,CONF>
- Type Parameters:
T- ClientTransport implementationCONF- Client Configuration implementation
- Direct Known Subclasses:
HttpClient,TcpClient,UdpClient
public abstract class ClientTransport<T extends ClientTransport<T,CONF>,CONF extends ClientTransportConfig<CONF>>
extends Transport<T,CONF>
- Since:
- 1.0.0
- Author:
- Stephane Maldini, Violeta Georgieva
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAn interface for selecting resolved addresses based on configuration and available socket addresses. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Mono<? extends Connection>connect()protected ConnectionBlock theClientTransportand return aConnection.protected ConnectionconnectNow(Duration timeout) Block theClientTransportand return aConnection.final TdoAfterResolve(BiConsumer<? super Connection, ? super SocketAddress> doAfterResolve) Set or add a callback called afterSocketAddressis resolved successfully.doOnConnect(Consumer<? super CONF> doOnConnect) Set or add a callback called whenClientTransportis about to connect to the remote endpoint.doOnConnected(Consumer<? super Connection> doOnConnected) Set or add a callback called afterConnectionhas been connected.doOnDisconnected(Consumer<? super Connection> doOnDisconnected) Set or add a callback called afterConnectionhas been disconnected.final TdoOnResolve(Consumer<? super Connection> doOnResolve) Set or add a callback called beforeSocketAddressis resolved.final TdoOnResolveError(BiConsumer<? super Connection, ? super Throwable> doOnResolveError) Set or add a callback called if an exception happens while resolving to aSocketAddress.The host to which this client should connect.noProxy()Remove any previously applied Proxy configuration customization.port(int port) The port to which this client should connect.proxy(Consumer<? super ProxyProvider.TypeSpec> proxyOptions) Apply a proxy configuration.final TSet up a proxy from the java system properties.remoteAddress(Supplier<? extends SocketAddress> remoteAddressSupplier) The address to which this client should connect on each subscribe.resolvedAddressesSelector(ClientTransport.ResolvedAddressSelector<? super CONF> resolvedAddressesSelector) Determines the resolved addresses to which this client should connect for each subscription.resolver(AddressResolverGroup<?> resolver) Assign anAddressResolverGroup.resolver(Consumer<NameResolverProvider.NameResolverSpec> nameResolverSpec) Apply a name resolver configuration.runOn(LoopResources loopResources, boolean preferNative) Run IO loops on a suppliedEventLoopGroupfrom theLoopResourcescontainer.warmup()Based on the actual configuration, returns aMonothat triggers: an initialization of the event loop group an initialization of the host name resolver loads the necessary native libraries for the transport By default, when method is not used, theconnect operationabsorbs the extra time needed to initialize and load the resources.Methods inherited from class reactor.netty.transport.Transport
attr, bindAddress, channelGroup, configuration, doOnChannelInit, duplicate, metrics, metrics, observe, option, runOn, runOn, wiretap, wiretap, wiretap, wiretap, wiretap
-
Constructor Details
-
ClientTransport
public ClientTransport()
-
-
Method Details
-
connect
Connect theClientTransportand return aMonoofConnection. IfMonois cancelled, the underlying connection will be aborted. Once theConnectionhas been emitted and is not necessary anymore, disposing must be done by the user viaDisposableChannel.dispose().- Returns:
- a
MonoofConnection
-
connectNow
Block theClientTransportand return aConnection. Disposing must be done by the user viaDisposableChannel.dispose(). The max connection timeout is 45 seconds.- Returns:
- a
Connection
-
connectNow
Block theClientTransportand return aConnection. Disposing must be done by the user viaDisposableChannel.dispose().- Parameters:
timeout- connect timeout (resolution: ns)- Returns:
- a
Connection
-
doOnConnect
Set or add a callback called whenClientTransportis about to connect to the remote endpoint.- Parameters:
doOnConnect- a consumer observing connect events- Returns:
- a new
ClientTransportreference
-
doOnConnected
Set or add a callback called afterConnectionhas been connected.- Parameters:
doOnConnected- a consumer observing connected events- Returns:
- a new
ClientTransportreference
-
doOnDisconnected
Set or add a callback called afterConnectionhas been disconnected.- Parameters:
doOnDisconnected- a consumer observing disconnected events- Returns:
- a new
ClientTransportreference
-
doOnResolve
Set or add a callback called beforeSocketAddressis resolved.- Parameters:
doOnResolve- a consumer observing resolve events- Returns:
- a new
ClientTransportreference - Since:
- 1.0.1
-
doAfterResolve
Set or add a callback called afterSocketAddressis resolved successfully.- Parameters:
doAfterResolve- a consumer observing resolved events- Returns:
- a new
ClientTransportreference - Since:
- 1.0.1
-
doOnResolveError
Set or add a callback called if an exception happens while resolving to aSocketAddress.- Parameters:
doOnResolveError- a consumer observing resolve error events- Returns:
- a new
ClientTransportreference - Since:
- 1.0.1
-
host
The host to which this client should connect.- Parameters:
host- the host to connect to- Returns:
- a new
ClientTransportreference
-
noProxy
Remove any previously applied Proxy configuration customization.- Returns:
- a new
ClientTransportreference
-
port
The port to which this client should connect.- Parameters:
port- the port to connect to- Returns:
- a new
ClientTransportreference
-
proxy
Apply a proxy configuration.- Parameters:
proxyOptions- the proxy configuration callback- Returns:
- a new
ClientTransportreference
-
proxyWithSystemProperties
Set up a proxy from the java system properties. Supports http, https, socks4, socks5 proxies. List of supported system properties https://docs.oracle.com/javase/7/docs/api/java/net/doc-files/net-properties.htmlIf both
https.proxyHostandhttp.proxyHostare set it chooseshttps.proxyHostoverhttp.proxyHost. Same with the http/https proxy port.If a
ClientTransportinstance already has a proxy set viaproxy(Consumer)the new instance created by this method has all proxy settings replaced with proxy settings from the system properties only.If the system properties do not have a configuration for a proxy, the new instance returned by this method behaves as if there is no proxy settings, regardless of configuration of the original
ClientTransportinstance.- Returns:
- a new
ClientTransportreference - Since:
- 1.0.8
-
remoteAddress
The address to which this client should connect on each subscribe.- Parameters:
remoteAddressSupplier- A supplier of the address to connect to.- Returns:
- a new
ClientTransport
-
resolvedAddressesSelector
public T resolvedAddressesSelector(ClientTransport.ResolvedAddressSelector<? super CONF> resolvedAddressesSelector) Determines the resolved addresses to which this client should connect for each subscription.- Parameters:
resolvedAddressesSelector- aClientTransport.ResolvedAddressSelectorinvoked after resolving the remote address to determine which addresses should be used for the connection.- Returns:
- a new
ClientTransport - Since:
- 1.2.5
-
resolver
Assign anAddressResolverGroup.- Parameters:
resolver- the newAddressResolverGroup- Returns:
- a new
ClientTransportreference
-
resolver
Apply a name resolver configuration.- Parameters:
nameResolverSpec- the name resolver callback- Returns:
- a new
ClientTransportreference
-
runOn
Description copied from class:TransportRun IO loops on a suppliedEventLoopGroupfrom theLoopResourcescontainer.- Overrides:
runOnin classTransport<T extends ClientTransport<T,CONF>, CONF extends ClientTransportConfig<CONF>> - Parameters:
loopResources- a new loop resourcespreferNative- should prefer running on epoll, io_uring, kqueue or similar instead of java NIO- Returns:
- a new
Transportreference
-
warmup
Based on the actual configuration, returns aMonothat triggers:- an initialization of the event loop group
- an initialization of the host name resolver
- loads the necessary native libraries for the transport
connect operationabsorbs the extra time needed to initialize and load the resources.- Returns:
- a
Monorepresenting the completion of the warmup - Since:
- 1.0.3
-