public abstract class UdpClient extends Object
connect(Bootstrap) is ultimately called.
Internally, materialization happens in two phases, first configure() is
called to retrieve a ready to use Bootstrap then connect(Bootstrap)
is 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 |
|---|---|
UdpClient |
addressSupplier(java.util.function.Supplier<? extends SocketAddress> connectingAddressSupplier)
Deprecated.
as of 0.9.7. Use
remoteAddress(Supplier) |
<T> UdpClient |
attr(AttributeKey<T> key,
T value)
Inject default attribute to the future child
Channel connections. |
UdpClient |
bindAddress(java.util.function.Supplier<? extends SocketAddress> bindAddressSupplier)
The address to which this client should bind on subscribe.
|
UdpClient |
bootstrap(java.util.function.Function<? super Bootstrap,? extends Bootstrap> bootstrapMapper)
Deprecated.
as of 0.9.10. Use the methods exposed on
UdpClient level. The method
will be removed in version 1.0.0. |
protected Bootstrap |
configure()
Materialize a Bootstrap from the parent
UdpClient chain to use with connect(Bootstrap) or separately |
Mono<? extends Connection> |
connect()
|
protected abstract Mono<? extends Connection> |
connect(Bootstrap b)
|
Connection |
connectNow(java.time.Duration timeout)
Block the
UdpClient and return a Connection. |
static UdpClient |
create()
Prepare a
UdpClient |
UdpClient |
doOnConnect(java.util.function.Consumer<? super Bootstrap> doOnConnect)
Setup a callback called when
Channel is about to
connect. |
UdpClient |
doOnConnected(java.util.function.Consumer<? super Connection> doOnConnected)
Setup a callback called when
Channel is
connected. |
UdpClient |
doOnDisconnected(java.util.function.Consumer<? super Connection> doOnDisconnected)
Setup a callback called when
Channel is
disconnected. |
UdpClient |
doOnLifecycle(java.util.function.Consumer<? super Bootstrap> doOnConnect,
java.util.function.Consumer<? super Connection> doOnConnected,
java.util.function.Consumer<? super Connection> doOnDisconnected)
Deprecated.
as of 0.9.7. Use
doOnConnect(Consumer), doOnConnected(Consumer)
or doOnDisconnected(Consumer) |
UdpClient |
handle(java.util.function.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 metricsEnabled)
Whether to enable metrics to be collected and registered in Micrometer's
globalRegistry
under the name Metrics.UDP_CLIENT_PREFIX. |
UdpClient |
metrics(boolean metricsEnabled,
ChannelMetricsRecorder recorder)
Deprecated.
as of 0.9.7. Use
metrics(boolean, Supplier) |
UdpClient |
metrics(boolean metricsEnabled,
java.util.function.Supplier<? extends ChannelMetricsRecorder> recorder)
Specifies whether the metrics are enabled on the
UdpClient. |
UdpClient |
observe(ConnectionObserver observer)
Setup all lifecycle callbacks called on or after
Channel
has been connected and after it has been disconnected. |
<T> UdpClient |
option(ChannelOption<T> key,
T value)
|
UdpClient |
port(int port)
The port to which this client should connect.
|
UdpClient |
remoteAddress(java.util.function.Supplier<? extends SocketAddress> remoteAddressSupplier)
The address to which this client should connect on 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 channelResources,
boolean preferNative)
Run IO loops on a supplied
EventLoopGroup from the LoopResources
container. |
UdpClient |
runOn(LoopResources channelResources,
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
UdpClient category
and DEBUG logger level |
UdpClient |
wiretap(String category)
Apply a wire logger configuration using the specified category
and
DEBUG logger level |
UdpClient |
wiretap(String category,
LogLevel level)
Apply a wire logger configuration using the specified category
and logger level
|
@Deprecated public final UdpClient addressSupplier(java.util.function.Supplier<? extends SocketAddress> connectingAddressSupplier)
remoteAddress(Supplier)connectingAddressSupplier - A supplier of the address to connect to.UdpClientpublic final UdpClient remoteAddress(java.util.function.Supplier<? extends SocketAddress> remoteAddressSupplier)
remoteAddressSupplier - A supplier of the address to connect to.UdpClientpublic final <T> UdpClient attr(AttributeKey<T> key, T value)
Channel connections. They
will be available via AttributeMap.attr(AttributeKey).T - the attribute typekey - the attribute keyvalue - the attribute valueUdpClientAbstractBootstrap.attr(AttributeKey, Object)public final UdpClient bindAddress(java.util.function.Supplier<? extends SocketAddress> bindAddressSupplier)
bindAddressSupplier - A supplier of the address to bind to.UdpClient@Deprecated public final UdpClient bootstrap(java.util.function.Function<? super Bootstrap,? extends Bootstrap> bootstrapMapper)
UdpClient level. The method
will be removed in version 1.0.0.Bootstrap configuration given mapper taking currently configured one
and returning a new one to be ultimately used for socket binding. Configuration
will apply during configure() phase.
bootstrapMapper - A bootstrap mapping function to update configuration and return an
enriched bootstrap.UdpClientpublic final Mono<? extends Connection> connect()
UdpClient 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 main client
loop must be done by the user via DisposableChannel.dispose().
If update configuration phase fails, a Mono.error(Throwable) will be returnedMono of Connectionpublic final Connection connectNow(java.time.Duration timeout)
UdpClient and return a Connection. Disposing must be
done by the user via DisposableChannel.dispose().timeout - connect timeoutMono of Connectionpublic final UdpClient doOnConnect(java.util.function.Consumer<? super Bootstrap> doOnConnect)
Channel is about to
connect.doOnConnect - a consumer observing client start eventUdpClientpublic final UdpClient doOnConnected(java.util.function.Consumer<? super Connection> doOnConnected)
Channel is
connected.doOnConnected - a consumer observing client started eventUdpClientpublic final UdpClient doOnDisconnected(java.util.function.Consumer<? super Connection> doOnDisconnected)
Channel is
disconnected.doOnDisconnected - a consumer observing client stop eventUdpClient@Deprecated public final UdpClient doOnLifecycle(java.util.function.Consumer<? super Bootstrap> doOnConnect, java.util.function.Consumer<? super Connection> doOnConnected, java.util.function.Consumer<? super Connection> doOnDisconnected)
doOnConnect(Consumer), doOnConnected(Consumer)
or doOnDisconnected(Consumer)Channel
has been connected and after it has been disconnected.doOnConnect - a consumer observing client start eventdoOnConnected - a consumer observing client started eventdoOnDisconnected - a consumer observing client stop eventUdpClientpublic final UdpClient host(String host)
host - The host to connect to.UdpClientpublic final UdpClient handle(java.util.function.BiFunction<? super UdpInbound,? super UdpOutbound,? extends Publisher<Void>> handler)
public final UdpClient observe(ConnectionObserver observer)
Channel
has been connected and after it has been disconnected.observer - a consumer observing state changesUdpClientpublic final <T> UdpClient option(ChannelOption<T> key, T value)
ChannelOption value for low level connection settings like SO_TIMEOUT
or SO_KEEPALIVE. This will apply to each new channel from remote peer.T - the option typekey - the option keyvalue - the option valueUdpClientAbstractBootstrap.option(ChannelOption, Object)public final UdpClient port(int port)
port - The port to connect to.UdpClientpublic final UdpClient runOn(EventLoopGroup eventLoopGroup)
EventLoopGroup.eventLoopGroup - an eventLoopGroup to shareUdpClientpublic final UdpClient runOn(LoopResources channelResources)
EventLoopGroup from the LoopResources
container. Will prefer native (epoll/kqueue) implementation if available unless the
environment property reactor.netty.native is set to false.channelResources - a LoopResources accepting native runtime
expectation and returning an eventLoopGroupUdpClientpublic final UdpClient runOn(LoopResources channelResources, boolean preferNative)
EventLoopGroup from the LoopResources
container.channelResources - a LoopResources accepting native runtime
expectation and returning an eventLoopGroup.preferNative - Should the connector prefer native (epoll/kqueue) if available.UdpClientpublic final UdpClient runOn(LoopResources channelResources, InternetProtocolFamily family)
EventLoopGroup from the LoopResources
container.channelResources - a LoopResources accepting native runtime
expectation and returning an eventLoopGroup.family - a specific InternetProtocolFamily to run withUdpClientpublic final UdpClient metrics(boolean metricsEnabled)
globalRegistry
under the name Metrics.UDP_CLIENT_PREFIX. Applications can
separately register their own
filters associated with this name.
For example, to put an upper bound on the number of tags produced:
MeterFilter filter = ... ; Metrics.globalRegistry.config().meterFilter(MeterFilter.maximumAllowableTags(UDP_CLIENT_PREFIX, 100, filter));
By default this is not enabled.
metricsEnabled - true enables metrics collection; false disables itUdpClient@Deprecated public final UdpClient metrics(boolean metricsEnabled, ChannelMetricsRecorder recorder)
metrics(boolean, Supplier)UdpClient.
All generated metrics are provided to the specified recorder.metricsEnabled - if true enables the metrics on the client.recorder - the ChannelMetricsRecorderUdpClientpublic final UdpClient metrics(boolean metricsEnabled, java.util.function.Supplier<? extends ChannelMetricsRecorder> recorder)
UdpClient.
All generated metrics are provided to the specified recorder
which is only instantiated if metrics are being enabled.metricsEnabled - if true enables the metrics on the client.recorder - a supplier for the ChannelMetricsRecorderUdpClientpublic final UdpClient wiretap(boolean enable)
UdpClient category
and DEBUG logger levelenable - Specifies whether the wire logger configuration will be added to
the pipelineUdpClientpublic final UdpClient wiretap(String category)
DEBUG logger levelcategory - the logger categoryUdpClientpublic final UdpClient wiretap(String category, LogLevel level)
category - the logger categorylevel - the logger levelUdpClientprotected Bootstrap configure()
UdpClient chain to use with connect(Bootstrap) or separatelyBootstrapprotected abstract Mono<? extends Connection> connect(Bootstrap b)
b - the Bootstrap to connectMono of Connection