T
- ClientTransport implementationCONF
- Client Configuration implementationpublic abstract class ClientTransport<T extends ClientTransport<T,CONF>,CONF extends ClientTransportConfig<CONF>> extends Transport<T,CONF>
Constructor and Description |
---|
ClientTransport() |
Modifier and Type | Method and Description |
---|---|
protected Mono<? extends Connection> |
connect()
|
protected Connection |
connectNow()
Block the
ClientTransport and return a Connection . |
protected Connection |
connectNow(Duration timeout)
Block the
ClientTransport and return a Connection . |
T |
doAfterResolve(BiConsumer<? super Connection,? super SocketAddress> doAfterResolve)
Set or add a callback called after
SocketAddress is resolved successfully. |
T |
doOnConnect(Consumer<? super CONF> doOnConnect)
Set or add a callback called when
ClientTransport is about to connect to the remote endpoint. |
T |
doOnConnected(Consumer<? super Connection> doOnConnected)
Set or add a callback called after
Connection has been connected. |
T |
doOnDisconnected(Consumer<? super Connection> doOnDisconnected)
Set or add a callback called after
Connection has been disconnected. |
T |
doOnResolve(Consumer<? super Connection> doOnResolve)
Set or add a callback called before
SocketAddress is resolved. |
T |
doOnResolveError(BiConsumer<? super Connection,? super Throwable> doOnResolveError)
Set or add a callback called if an exception happens while resolving to a
SocketAddress . |
T |
host(String host)
The host to which this client should connect.
|
T |
noProxy()
Remove any previously applied Proxy configuration customization.
|
T |
port(int port)
The port to which this client should connect.
|
T |
proxy(Consumer<? super ProxyProvider.TypeSpec> proxyOptions)
Apply a proxy configuration.
|
T |
proxyWithSystemProperties()
Set up a proxy from the java system properties.
|
T |
remoteAddress(Supplier<? extends SocketAddress> remoteAddressSupplier)
The address to which this client should connect on each subscribe.
|
T |
resolver(AddressResolverGroup<?> resolver)
Assign an
AddressResolverGroup . |
T |
resolver(Consumer<NameResolverProvider.NameResolverSpec> nameResolverSpec)
Apply a name resolver configuration.
|
T |
runOn(LoopResources loopResources,
boolean preferNative)
Run IO loops on a supplied
EventLoopGroup from the LoopResources container. |
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. |
attr, bindAddress, channelGroup, configuration, doOnChannelInit, duplicate, metrics, metrics, observe, option, runOn, runOn, wiretap, wiretap, wiretap, wiretap, wiretap
protected Mono<? extends Connection> connect()
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 DisposableChannel.dispose()
.Mono
of Connection
protected Connection connectNow()
ClientTransport
and return a Connection
. Disposing must be
done by the user via DisposableChannel.dispose()
. The max connection
timeout is 45 seconds.Connection
protected Connection connectNow(Duration timeout)
ClientTransport
and return a Connection
. Disposing must be
done by the user via DisposableChannel.dispose()
.timeout
- connect timeout (resolution: ns)Connection
public T doOnConnect(Consumer<? super CONF> doOnConnect)
ClientTransport
is about to connect to the remote endpoint.doOnConnect
- a consumer observing connect eventsClientTransport
referencepublic T doOnConnected(Consumer<? super Connection> doOnConnected)
Connection
has been connected.doOnConnected
- a consumer observing connected eventsClientTransport
referencepublic T doOnDisconnected(Consumer<? super Connection> doOnDisconnected)
Connection
has been disconnected.doOnDisconnected
- a consumer observing disconnected eventsClientTransport
referencepublic final T doOnResolve(Consumer<? super Connection> doOnResolve)
SocketAddress
is resolved.doOnResolve
- a consumer observing resolve eventsClientTransport
referencepublic final T doAfterResolve(BiConsumer<? super Connection,? super SocketAddress> doAfterResolve)
SocketAddress
is resolved successfully.doAfterResolve
- a consumer observing resolved eventsClientTransport
referencepublic final T doOnResolveError(BiConsumer<? super Connection,? super Throwable> doOnResolveError)
SocketAddress
.doOnResolveError
- a consumer observing resolve error eventsClientTransport
referencepublic T host(String host)
host
- the host to connect toClientTransport
referencepublic T noProxy()
ClientTransport
referencepublic T port(int port)
port
- the port to connect toClientTransport
referencepublic T proxy(Consumer<? super ProxyProvider.TypeSpec> proxyOptions)
proxyOptions
- the proxy configuration callbackClientTransport
referencepublic final T proxyWithSystemProperties()
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 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.
ClientTransport
referencepublic T remoteAddress(Supplier<? extends SocketAddress> remoteAddressSupplier)
remoteAddressSupplier
- A supplier of the address to connect to.ClientTransport
public T resolver(AddressResolverGroup<?> resolver)
AddressResolverGroup
.resolver
- the new AddressResolverGroup
ClientTransport
referencepublic T resolver(Consumer<NameResolverProvider.NameResolverSpec> nameResolverSpec)
nameResolverSpec
- the name resolver callbackClientTransport
referencepublic T runOn(LoopResources loopResources, boolean preferNative)
Transport
EventLoopGroup
from the LoopResources
container.runOn
in class Transport<T extends ClientTransport<T,CONF>,CONF extends ClientTransportConfig<CONF>>
loopResources
- a new loop resourcespreferNative
- should prefer running on epoll, kqueue or similar instead of java NIOTransport
referencepublic Mono<Void> warmup()
Mono
that triggers:
connect operation
absorbs the extra time needed to initialize and
load the resources.Mono
representing the completion of the warmup