Top Description Fields Constructors Methods
reactor.netty5.transport

public abstract Class ClientTransport<T extends reactor.netty5.transport.ClientTransport<T, CONF>, CONF extends reactor.netty5.transport.ClientTransportConfig<CONF>>

extends Transport<T extends ClientTransport<T, CONF>, CONF extends ClientTransportConfig<CONF>>
Class Inheritance
Known Direct Subclasses
reactor.netty5.udp.UdpClient, reactor.netty5.tcp.TcpClient
Type Parameters
<T>
ClientTransport implementation
<CONF>
Client Configuration implementation
Imports
java.net.SocketAddress, java.time.Duration, java.util.Objects, .Properties, java.util.function.BiConsumer, .Consumer, .Supplier, io.netty5.resolver.AddressResolverGroup, .NoopAddressResolverGroup, reactor.core.publisher.Mono, reactor.netty5.Connection, .ConnectionObserver, reactor.netty5.resources.LoopResources, reactor.util.annotation.Nullable

A generic client Transport that will connect() to a remote address and provide a Connection
Authors
Stephane Maldini, Violeta Georgieva
Since
1.0.0

Field Summary

Inherited from reactor.netty5.transport.Transport:
log

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected Mono<? extends Connection>

Returns:

a Mono of Connection
connect
()

Connect the ClientTransport and return a Mono of Connection.

protected Connection

Returns:

a Connection
connectNow
()

Block the ClientTransport and return a Connection.

protected Connection

Returns:

a Connection
connectNow
(Duration
connect timeout (resolution: ns)
timeout
)

Block the ClientTransport and return a Connection.

public final T

Returns:

a new ClientTransport reference
doAfterResolve
(BiConsumer<? super Connection, ? super SocketAddress>
a consumer observing resolved events
doAfterResolve
)

Set or add a callback called after SocketAddress is resolved successfully.

public T

Returns:

a new ClientTransport reference
doOnConnect
(Consumer<? super CONF>
a consumer observing connect events
doOnConnect
)

Set or add a callback called when ClientTransport is about to connect to the remote endpoint.

public T

Returns:

a new ClientTransport reference
doOnConnected
(Consumer<? super Connection>
a consumer observing connected events
doOnConnected
)

Set or add a callback called after Connection has been connected.

public T

Returns:

a new ClientTransport reference
doOnDisconnected
(Consumer<? super Connection>
a consumer observing disconnected events
doOnDisconnected
)

Set or add a callback called after Connection has been disconnected.

public final T

Returns:

a new ClientTransport reference
doOnResolve
(Consumer<? super Connection>
a consumer observing resolve events
doOnResolve
)

Set or add a callback called before SocketAddress is resolved.

public final T

Returns:

a new ClientTransport reference
doOnResolveError
(BiConsumer<? super Connection, ? super Throwable>
a consumer observing resolve error events
doOnResolveError
)

Set or add a callback called if an exception happens while resolving to a SocketAddress.

public T

Returns:

a new ClientTransport reference
host
(String
the host to connect to
host
)

The host to which this client should connect.

public T

Returns:

a new ClientTransport reference
noProxy
()

Remove any previously applied Proxy configuration customization

public T

Returns:

a new ClientTransport reference
port
(int
the port to connect to
port
)

The port to which this client should connect.

public T

Returns:

a new ClientTransport reference
proxy
(Consumer<? super ProxyProvider.TypeSpec>
the proxy configuration callback
proxyOptions
)

Apply a proxy configuration

protected ProxyProvider
protected ProxyProvider
pack-priv final T
public final T

Returns:

a new ClientTransport reference
proxyWithSystemProperties
()

Set up a proxy from the java system properties.

pack-priv final T

Returns:

a new ClientTransport reference
proxyWithSystemProperties
(Properties properties)

Same as proxyWithSystemProperties() but accepts properties and used in testing only.

public T

Returns:

a new ClientTransport
remoteAddress
(Supplier<? extends SocketAddress>
A supplier of the address to connect to.
remoteAddressSupplier
)

The address to which this client should connect on each subscribe.

public T

Returns:

a new ClientTransport reference
resolver
(AddressResolverGroup<?> resolver)

Assign an AddressResolverGroup.

public T

Returns:

a new ClientTransport reference
resolver
(Consumer<NameResolverProvider.NameResolverSpec>
the name resolver callback
nameResolverSpec
)

Apply a name resolver configuration.

public T
runOn(LoopResources
a new loop resources
loopResources
,
boolean
should prefer running on epoll, kqueue or similar instead of java NIO
preferNative
)

Overrides reactor.netty5.transport.Transport.runOn.

Run IO loops on a supplied EventLoopGroup from the LoopResources container.
public Mono<Void>

Returns:

a Mono representing the completion of the warmup
warmup
()

Based on the actual configuration, returns a Mono that triggers:

  • an initialization of the event loop group
  • an initialization of the host name resolver
  • loads the necessary native libraries for the transport
Inherited from reactor.netty5.transport.Transport:
attrbindAddresschannelGroupconfigurationdoOnChannelInitduplicatemetricsmetricsobserveoptionrunOnrunOnrunOnwiretapwiretapwiretapwiretapwiretap

Constructor Detail

ClientTransportback to summary
public ClientTransport()

Method Detail

connectback to summary
protected Mono<? extends Connection> connect()

Connect the ClientTransport and return a Mono of Connection. If Mono is cancelled, the underlying connection will be aborted. Once the Connection has been emitted and is not necessary anymore, disposing must be done by the user via Connection#dispose().

Returns:Mono<? extends Connection>

a Mono of Connection

connectNowback to summary
protected Connection connectNow()

Block the ClientTransport and return a Connection. Disposing must be done by the user via Connection#dispose(). The max connection timeout is 45 seconds.

Returns:Connection

a Connection

connectNowback to summary
protected Connection connectNow(Duration timeout)

Block the ClientTransport and return a Connection. Disposing must be done by the user via Connection#dispose().

Parameters
timeout:Duration

connect timeout (resolution: ns)

Returns:Connection

a Connection

doAfterResolveback to summary
public final T doAfterResolve(BiConsumer<? super Connection, ? super SocketAddress> doAfterResolve)

Set or add a callback called after SocketAddress is resolved successfully.

Parameters
doAfterResolve:BiConsumer<? super Connection, ? super SocketAddress>

a consumer observing resolved events

Returns:T

a new ClientTransport reference

Since
1.0.1
doOnConnectback to summary
public T doOnConnect(Consumer<? super CONF> doOnConnect)

Set or add a callback called when ClientTransport is about to connect to the remote endpoint.

Parameters
doOnConnect:Consumer<? super CONF>

a consumer observing connect events

Returns:T

a new ClientTransport reference

doOnConnectedback to summary
public T doOnConnected(Consumer<? super Connection> doOnConnected)

Set or add a callback called after Connection has been connected.

Parameters
doOnConnected:Consumer<? super Connection>

a consumer observing connected events

Returns:T

a new ClientTransport reference

doOnDisconnectedback to summary
public T doOnDisconnected(Consumer<? super Connection> doOnDisconnected)

Set or add a callback called after Connection has been disconnected.

Parameters
doOnDisconnected:Consumer<? super Connection>

a consumer observing disconnected events

Returns:T

a new ClientTransport reference

doOnResolveback to summary
public final T doOnResolve(Consumer<? super Connection> doOnResolve)

Set or add a callback called before SocketAddress is resolved.

Parameters
doOnResolve:Consumer<? super Connection>

a consumer observing resolve events

Returns:T

a new ClientTransport reference

Since
1.0.1
doOnResolveErrorback to summary
public final T doOnResolveError(BiConsumer<? super Connection, ? super Throwable> doOnResolveError)

Set or add a callback called if an exception happens while resolving to a SocketAddress.

Parameters
doOnResolveError:BiConsumer<? super Connection, ? super Throwable>

a consumer observing resolve error events

Returns:T

a new ClientTransport reference

Since
1.0.1
hostback to summary
public T host(String host)

The host to which this client should connect.

Parameters
host:String

the host to connect to

Returns:T

a new ClientTransport reference

noProxyback to summary
public T noProxy()

Remove any previously applied Proxy configuration customization

Returns:T

a new ClientTransport reference

portback to summary
public T port(int port)

The port to which this client should connect.

Parameters
port:int

the port to connect to

Returns:T

a new ClientTransport reference

proxyback to summary
public T proxy(Consumer<? super ProxyProvider.TypeSpec> proxyOptions)

Apply a proxy configuration

Parameters
proxyOptions:Consumer<? super ProxyProvider.TypeSpec>

the proxy configuration callback

Returns:T

a new ClientTransport reference

proxyProviderFromback to summary
protected ProxyProvider proxyProviderFrom(Consumer<? super ProxyProvider.TypeSpec> proxyOptions)
proxyProviderFromback to summary
protected ProxyProvider proxyProviderFrom(Properties properties)
Annotations
@Nullable
proxyWithProxyProviderback to summary
pack-priv final T proxyWithProxyProvider(ProxyProvider proxy)
proxyWithSystemPropertiesback to summary
public final T 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.html

If both https.proxyHost and http.proxyHost are set it chooses https.proxyHost over http.proxyHost. Same with the http/https proxy port.

If a ClientTransport instance already has a proxy set via ClientTransport#proxy(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 ClientTransport instance.

Returns:T

a new ClientTransport reference

Since
1.0.8
proxyWithSystemPropertiesback to summary
pack-priv final T proxyWithSystemProperties(Properties properties)

Same as proxyWithSystemProperties() but accepts properties and used in testing only.

Returns:T

a new ClientTransport reference

remoteAddressback to summary
public T remoteAddress(Supplier<? extends SocketAddress> remoteAddressSupplier)

The address to which this client should connect on each subscribe.

Parameters
remoteAddressSupplier:Supplier<? extends SocketAddress>

A supplier of the address to connect to.

Returns:T

a new ClientTransport

resolverback to summary
public T resolver(AddressResolverGroup<?> resolver)

Assign an AddressResolverGroup.

Parameters
resolver:AddressResolverGroup<?>

the new AddressResolverGroup

Returns:T

a new ClientTransport reference

resolverback to summary
public T resolver(Consumer<NameResolverProvider.NameResolverSpec> nameResolverSpec)

Apply a name resolver configuration.

Parameters
nameResolverSpec:Consumer<NameResolverProvider.NameResolverSpec>

the name resolver callback

Returns:T

a new ClientTransport reference

runOnback to summary
public T runOn(LoopResources loopResources, boolean preferNative)

Overrides reactor.netty5.transport.Transport.runOn.

Doc from reactor.netty5.transport.Transport.runOn.

Run IO loops on a supplied EventLoopGroup from the LoopResources container.

Parameters
loopResources:LoopResources

a new loop resources

preferNative:boolean

should prefer running on epoll, kqueue or similar instead of java NIO

Returns:T

a new Transport reference

Annotations
@Override
warmupback to summary
public Mono<Void> warmup()

Based on the actual configuration, returns a Mono that 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, the connect operation absorbs the extra time needed to initialize and load the resources.
Returns:Mono<Void>

a Mono representing the completion of the warmup

Since
1.0.3