T
- Transport implementationC
- Transport Config implementationpublic abstract class Transport<T extends Transport<T,C>,C extends TransportConfig> extends Object
Constructor and Description |
---|
Transport() |
Modifier and Type | Method and Description |
---|---|
<A> T |
attr(AttributeKey<A> key,
A value)
Update the given attribute key or remove it if the value is null.
|
T |
bindAddress(java.util.function.Supplier<? extends SocketAddress> bindAddressSupplier)
Set a new local address to which this transport should bind on subscribe.
|
T |
channelGroup(ChannelGroup channelGroup)
Provide a
ChannelGroup to hold all active connected channels. |
abstract C |
configuration()
Return a
TransportConfig . |
T |
doOnChannelInit(ChannelPipelineConfigurer doOnChannelInit)
Configure the channel pipeline while initializing the channel.
|
protected abstract T |
duplicate()
Return a new
Transport inheriting the current configuration. |
protected T |
metrics(boolean enable)
Whether to enable metrics to be collected and registered in Micrometer's
globalRegistry . |
T |
metrics(boolean enable,
java.util.function.Supplier<? extends ChannelMetricsRecorder> recorder)
Specifies whether the metrics are enabled on the
Transport . |
T |
observe(ConnectionObserver observer)
Set or add the given
ConnectionObserver to observe the connection state changes. |
<O> T |
option(ChannelOption<O> key,
O value)
Update the given option key or remove it if the value is null.
|
T |
runOn(EventLoopGroup eventLoopGroup)
Run IO loops on the given
EventLoopGroup . |
T |
runOn(LoopResources channelResources)
Run IO loops on a supplied
EventLoopGroup from the LoopResources container. |
T |
runOn(LoopResources loopResources,
boolean preferNative)
Run IO loops on a supplied
EventLoopGroup from the LoopResources container. |
T |
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. |
T |
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. |
T |
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. |
T |
wiretap(String category,
LogLevel level,
AdvancedByteBufFormat format)
Apply a wire logger configuration using the specified category (logger),
logger level and
ByteBuf format. |
T |
wiretap(String category,
LogLevel level,
AdvancedByteBufFormat format,
Charset charset)
Apply a wire logger configuration using the specific category (logger),
logger level,
ByteBuf format and charset. |
public <A> T attr(AttributeKey<A> key, @Nullable A value)
A
- the attribute typekey
- the AttributeKey
keyvalue
- the AttributeKey
valueTransport
referencepublic T bindAddress(java.util.function.Supplier<? extends SocketAddress> bindAddressSupplier)
bindAddressSupplier
- A supplier of the address to bind to.Transport
public T channelGroup(ChannelGroup channelGroup)
ChannelGroup
to hold all active connected channels.
Graceful Shutdown:
When a ChannelGroup
is set, calls to DisposableChannel.disposeNow()
and DisposableChannel.disposeNow(Duration)
not only stop accepting new requests
but also additionally wait for all active requests, in the ChannelGroup
, to
complete, within the given timeout.
channelGroup
- a ChannelGroup
Transport
referencepublic abstract C configuration()
TransportConfig
.TransportConfig
public T doOnChannelInit(ChannelPipelineConfigurer doOnChannelInit)
doOnChannelInit
- configure the channel pipeline while initializing the channelTransport
referenceprotected T metrics(boolean enable)
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.
enable
- true enables metrics collection; false disables itTransport
referencepublic T metrics(boolean enable, java.util.function.Supplier<? extends ChannelMetricsRecorder> recorder)
Transport
.
All generated metrics are provided to the specified recorder
which is only instantiated if metrics are being enabled.enable
- if true enables the metrics on the Transport
.recorder
- a supplier for the ChannelMetricsRecorder
Transport
referencepublic T observe(ConnectionObserver observer)
ConnectionObserver
to observe the connection state changes.observer
- the ConnectionObserver
to be set or addTransport
referencepublic <O> T option(ChannelOption<O> key, @Nullable O value)
ChannelOption.AUTO_READ
option will be ignored. It is configured to be false
.O
- the option typekey
- the ChannelOption
keyvalue
- the ChannelOption
value or nullTransport
referencepublic T runOn(EventLoopGroup eventLoopGroup)
EventLoopGroup
.eventLoopGroup
- an eventLoopGroup to shareTransport
referencepublic T 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 eventLoopGroupTransport
referencepublic T runOn(LoopResources loopResources, boolean preferNative)
EventLoopGroup
from the LoopResources
container.loopResources
- a new loop resourcespreferNative
- should prefer running on epoll, kqueue or similar instead of java NIOTransport
referencepublic T wiretap(boolean enable)
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.enable
- specifies whether the wire logger configuration will be added to the pipelineTransport
referencepublic T wiretap(String category)
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.category
- the logger categoryTransport
referencepublic T wiretap(String category, LogLevel level)
AdvancedByteBufFormat.HEX_DUMP
for ByteBuf
format,
which means both events and content will be logged and the content will be in hex format.category
- the logger categorylevel
- the logger levelTransport
referencepublic final T wiretap(String category, LogLevel level, AdvancedByteBufFormat format)
ByteBuf
format.
Depending on the format:
AdvancedByteBufFormat.SIMPLE
- only the events will be loggedAdvancedByteBufFormat.HEX_DUMP
- both events and content will be logged,
with content in hex formatAdvancedByteBufFormat.TEXTUAL
- both events and content will be logged,
with content in plain text formatAdvancedByteBufFormat.TEXTUAL
is specified, Charset.defaultCharset()
will be used.public final T wiretap(String category, LogLevel level, AdvancedByteBufFormat format, Charset charset)
ByteBuf
format and charset.
The charset is relevant in case of AdvancedByteBufFormat.TEXTUAL
and a different charset than Charset.defaultCharset()
is required.
Depending on the format:
AdvancedByteBufFormat.SIMPLE
- only the events will be loggedAdvancedByteBufFormat.HEX_DUMP
- both events and content will be logged,
with content in hex formatAdvancedByteBufFormat.TEXTUAL
- both events and content will be logged,
with content in plain text format