public abstract class UdpClient extends ClientTransport<UdpClient,UdpClientConfig>
connect()
is ultimately called.
Example:
UdpClient.create()
.doOnConnect(startMetrics)
.doOnConnected(startedMetrics)
.doOnDisconnected(stopMetrics)
.host("127.0.0.1")
.port(1234)
.connect()
.block()
Constructor and Description |
---|
UdpClient() |
Modifier and Type | Method and Description |
---|---|
<A> UdpClient |
attr(AttributeKey<A> key,
A value)
Update the given attribute key or remove it if the value is null.
|
UdpClient |
bindAddress(Supplier<? extends SocketAddress> bindAddressSupplier)
Set a new local address to which this transport should bind on subscribe.
|
Mono<? extends Connection> |
connect()
|
Connection |
connectNow()
Block the
ClientTransport and return a Connection . |
Connection |
connectNow(Duration timeout)
Block the
ClientTransport and return a Connection . |
static UdpClient |
create()
Prepare a
UdpClient . |
UdpClient |
doOnConnect(Consumer<? super UdpClientConfig> doOnConnect)
Set or add a callback called when
ClientTransport is about to connect to the remote endpoint. |
UdpClient |
doOnConnected(Consumer<? super Connection> doOnConnected)
Set or add a callback called after
Connection has been connected. |
UdpClient |
doOnDisconnected(Consumer<? super Connection> doOnDisconnected)
Set or add a callback called after
Connection has been disconnected. |
UdpClient |
handle(BiFunction<? super UdpInbound,? super UdpOutbound,? extends Publisher<Void>> handler)
Attach an IO handler to react on connected client.
|
UdpClient |
host(String host)
The host to which this client should connect.
|
UdpClient |
metrics(boolean enable)
Whether to enable metrics to be collected and registered in Micrometer's
globalRegistry . |
UdpClient |
metrics(boolean enable,
Supplier<? extends ChannelMetricsRecorder> recorder)
Specifies whether the metrics are enabled on the
Transport . |
UdpClient |
observe(ConnectionObserver observer)
Set or add the given
ConnectionObserver to observe the connection state changes. |
<O> UdpClient |
option(ChannelOption<O> key,
O value)
Update the given option key or remove it if the value is null.
|
UdpClient |
port(int port)
The port to which this client should connect.
|
UdpClient |
remoteAddress(Supplier<? extends SocketAddress> remoteAddressSupplier)
The address to which this client should connect on each subscribe.
|
UdpClient |
runOn(EventLoopGroup eventLoopGroup)
Run IO loops on the given
EventLoopGroup . |
UdpClient |
runOn(LoopResources channelResources)
Run IO loops on a supplied
EventLoopGroup from the LoopResources container. |
UdpClient |
runOn(LoopResources loopResources,
boolean preferNative)
Run IO loops on a supplied
EventLoopGroup from the LoopResources container. |
UdpClient |
runOn(LoopResources loopResources,
InternetProtocolFamily family)
Run IO loops on a supplied
EventLoopGroup from the LoopResources container. |
UdpClient |
wiretap(boolean enable)
Apply or remove a wire logger configuration using
Transport category (logger),
DEBUG logger level and AdvancedByteBufFormat.HEX_DUMP for ByteBuf format,
which means both events and content will be logged and the content will be in hex format. |
UdpClient |
wiretap(String category)
Apply a wire logger configuration using the specified category (logger),
DEBUG logger level and AdvancedByteBufFormat.HEX_DUMP for ByteBuf format,
which means both events and content will be logged and the content will be in hex format. |
UdpClient |
wiretap(String category,
LogLevel level)
Apply a wire logger configuration using the specified category (logger),
logger level and
AdvancedByteBufFormat.HEX_DUMP for ByteBuf format,
which means both events and content will be logged and the content will be in hex format. |
doAfterResolve, doOnResolve, doOnResolveError, noProxy, proxy, proxyWithSystemProperties, resolver, resolver, warmup
channelGroup, configuration, doOnChannelInit, duplicate, wiretap, wiretap
public final <A> UdpClient attr(AttributeKey<A> key, @Nullable A value)
Transport
attr
in class Transport<UdpClient,UdpClientConfig>
A
- the attribute typekey
- the AttributeKey
keyvalue
- the AttributeKey
valueTransport
referencepublic final UdpClient bindAddress(Supplier<? extends SocketAddress> bindAddressSupplier)
Transport
bindAddress
in class Transport<UdpClient,UdpClientConfig>
bindAddressSupplier
- A supplier of the address to bind to.Transport
public final Mono<? extends Connection> connect()
ClientTransport
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()
.connect
in class ClientTransport<UdpClient,UdpClientConfig>
Mono
of Connection
public final Connection connectNow()
ClientTransport
ClientTransport
and return a Connection
. Disposing must be
done by the user via DisposableChannel.dispose()
. The max connection
timeout is 45 seconds.connectNow
in class ClientTransport<UdpClient,UdpClientConfig>
Connection
public final Connection connectNow(Duration timeout)
ClientTransport
ClientTransport
and return a Connection
. Disposing must be
done by the user via DisposableChannel.dispose()
.connectNow
in class ClientTransport<UdpClient,UdpClientConfig>
timeout
- connect timeout (resolution: ns)Connection
public final UdpClient doOnConnect(Consumer<? super UdpClientConfig> doOnConnect)
ClientTransport
ClientTransport
is about to connect to the remote endpoint.doOnConnect
in class ClientTransport<UdpClient,UdpClientConfig>
doOnConnect
- a consumer observing connect eventsClientTransport
referencepublic final UdpClient doOnConnected(Consumer<? super Connection> doOnConnected)
ClientTransport
Connection
has been connected.doOnConnected
in class ClientTransport<UdpClient,UdpClientConfig>
doOnConnected
- a consumer observing connected eventsClientTransport
referencepublic final UdpClient doOnDisconnected(Consumer<? super Connection> doOnDisconnected)
ClientTransport
Connection
has been disconnected.doOnDisconnected
in class ClientTransport<UdpClient,UdpClientConfig>
doOnDisconnected
- a consumer observing disconnected eventsClientTransport
referencepublic final UdpClient handle(BiFunction<? super UdpInbound,? super UdpOutbound,? extends Publisher<Void>> handler)
public final UdpClient host(String host)
ClientTransport
host
in class ClientTransport<UdpClient,UdpClientConfig>
host
- the host to connect toClientTransport
referencepublic final UdpClient metrics(boolean enable)
Transport
globalRegistry
.
Applications can separately register their own
filters
.
For example, to put an upper bound on the number of tags produced:
MeterFilter filter = ... ; Metrics.globalRegistry.config().meterFilter(MeterFilter.maximumAllowableTags(prefix, 100, filter));
By default this is not enabled.
metrics
in class Transport<UdpClient,UdpClientConfig>
enable
- true enables metrics collection; false disables itTransport
referencepublic final UdpClient metrics(boolean enable, Supplier<? extends ChannelMetricsRecorder> recorder)
Transport
Transport
.
All generated metrics are provided to the specified recorder
which is only instantiated if metrics are being enabled (the instantiation is not lazy,
but happens immediately, while configuring the Transport
).metrics
in class Transport<UdpClient,UdpClientConfig>
enable
- if true enables the metrics on the Transport
.recorder
- a supplier for the ChannelMetricsRecorder
Transport
referencepublic final UdpClient observe(ConnectionObserver observer)
Transport
ConnectionObserver
to observe the connection state changes.observe
in class Transport<UdpClient,UdpClientConfig>
observer
- the ConnectionObserver
to be set or addTransport
referencepublic final <O> UdpClient option(ChannelOption<O> key, @Nullable O value)
Transport
ChannelOption.AUTO_READ
option will be ignored. It is configured to be false
.option
in class Transport<UdpClient,UdpClientConfig>
O
- the option typekey
- the ChannelOption
keyvalue
- the ChannelOption
value or nullTransport
referencepublic final UdpClient port(int port)
12012
is used.
Note: The port can be specified also with PORT
environment variable.
port
in class ClientTransport<UdpClient,UdpClientConfig>
port
- the port to connect toUdpClient
referencepublic final UdpClient remoteAddress(Supplier<? extends SocketAddress> remoteAddressSupplier)
ClientTransport
remoteAddress
in class ClientTransport<UdpClient,UdpClientConfig>
remoteAddressSupplier
- A supplier of the address to connect to.ClientTransport
public final UdpClient runOn(EventLoopGroup eventLoopGroup)
Transport
EventLoopGroup
.runOn
in class Transport<UdpClient,UdpClientConfig>
eventLoopGroup
- an eventLoopGroup to shareTransport
referencepublic final UdpClient runOn(LoopResources channelResources)
Transport
EventLoopGroup
from the LoopResources
container.
Will prefer native (epoll/kqueue) implementation if available
unless the environment property reactor.netty.native
is set to false
.runOn
in class Transport<UdpClient,UdpClientConfig>
channelResources
- a LoopResources
accepting native runtime expectation and
returning an eventLoopGroupTransport
referencepublic final UdpClient runOn(LoopResources loopResources, boolean preferNative)
EventLoopGroup
from the LoopResources
container.runOn
in class ClientTransport<UdpClient,UdpClientConfig>
loopResources
- a new loop resourcespreferNative
- should prefer running on epoll, kqueue or similar instead of java NIOUdpClient
referencepublic final UdpClient runOn(LoopResources loopResources, InternetProtocolFamily family)
EventLoopGroup
from the LoopResources
container.loopResources
- a new loop resourcesfamily
- a specific InternetProtocolFamily
to run withUdpClient
referencepublic final UdpClient wiretap(boolean enable)
Transport
Transport
category (logger),
DEBUG
logger level and AdvancedByteBufFormat.HEX_DUMP
for ByteBuf
format,
which means both events and content will be logged and the content will be in hex format.wiretap
in class Transport<UdpClient,UdpClientConfig>
enable
- specifies whether the wire logger configuration will be added to the pipelineTransport
referencepublic final UdpClient wiretap(String category)
Transport
DEBUG
logger level and AdvancedByteBufFormat.HEX_DUMP
for ByteBuf
format,
which means both events and content will be logged and the content will be in hex format.wiretap
in class Transport<UdpClient,UdpClientConfig>
category
- the logger categoryTransport
referencepublic final UdpClient wiretap(String category, LogLevel level)
Transport
AdvancedByteBufFormat.HEX_DUMP
for ByteBuf
format,
which means both events and content will be logged and the content will be in hex format.wiretap
in class Transport<UdpClient,UdpClientConfig>
category
- the logger categorylevel
- the logger levelTransport
reference