Top Description Fields Constructors Methods
reactor.netty.transport

public abstract Class Transport<T extends reactor.netty.transport.Transport<T, C>, C extends reactor.netty.transport.TransportConfig>

extends Object
Class Inheritance
Known Direct Subclasses
reactor.netty.udp.UdpServer, reactor.netty.transport.ClientTransport, reactor.netty.transport.ServerTransport
Type Parameters
<T>
Transport implementation
<C>
Transport Config implementation
Imports
java.net.SocketAddress, java.nio.charset.Charset, java.time.Duration, java.util.Objects, java.util.function.Supplier, io.netty.buffer.ByteBuf, io.netty.channel.ChannelOption, .EventLoopGroup, io.netty.channel.group.ChannelGroup, io.netty.handler.logging.LogLevel, .LoggingHandler, io.netty.util.AttributeKey, reactor.netty.ChannelPipelineConfigurer, .ConnectionObserver, .DisposableChannel, reactor.netty.channel.ChannelMetricsRecorder, reactor.netty.internal.util.Metrics, reactor.netty.transport.logging.AdvancedByteBufFormat, reactor.netty.resources.LoopResources, reactor.util.Logger, .Loggers, reactor.util.annotation.Nullable

An immutable transport builder for clients and servers.
Authors
Stephane Maldini, Violeta Georgieva
Since
1.0.0

Field Summary

Modifier and TypeField and Description
pack-priv static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public <
the attribute type
A
>
T

Returns:

a new Transport reference
attr
(AttributeKey<A>
the AttributeKey key
key
,
A
the AttributeKey value
value
)

Update the given attribute key or remove it if the value is null.

public T

Returns:

a new Transport
bindAddress
(Supplier<? extends SocketAddress>
A supplier of the address to bind to.
bindAddressSupplier
)

Set a new local address to which this transport should bind on subscribe.

public T

Returns:

a new Transport reference
channelGroup
(ChannelGroup channelGroup)

Provide a ChannelGroup to hold all active connected channels.

public abstract C
public T

Returns:

a new Transport reference
doOnChannelInit
(ChannelPipelineConfigurer
configure the channel pipeline while initializing the channel
doOnChannelInit
)

Configure the channel pipeline while initializing the channel.

protected abstract T

Returns:

a new Transport inheriting the current configuration
duplicate
()

Return a new Transport inheriting the current configuration.

protected T

Returns:

a new Transport reference
metrics
(boolean
true enables metrics collection; false disables it
enable
)

Whether to enable metrics to be collected and registered in Micrometer's globalRegistry.

public T

Returns:

a new Transport reference
metrics
(boolean
if true enables the metrics on the Transport.
enable
,
Supplier<? extends ChannelMetricsRecorder>
a supplier for the ChannelMetricsRecorder
recorder
)

Specifies whether the metrics are enabled on the Transport.

public T

Returns:

a new Transport reference
observe
(ConnectionObserver
the ConnectionObserver to be set or add
observer
)

Set or add the given ConnectionObserver to observe the connection state changes.

public <
the option type
O
>
T

Returns:

a new Transport reference
option
(ChannelOption<O> key, O
the ChannelOption value or null
value
)

Update the given option key or remove it if the value is null.

public T

Returns:

a new Transport reference
runOn
(EventLoopGroup
an eventLoopGroup to share
eventLoopGroup
)

Run IO loops on the given EventLoopGroup.

public T

Returns:

a new Transport reference
runOn
(LoopResources
a LoopResources accepting native runtime expectation and returning an eventLoopGroup
channelResources
)

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

public T

Returns:

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

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

public T

Returns:

a new Transport reference
wiretap
(boolean
specifies whether the wire logger configuration will be added to the pipeline
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.

public T

Returns:

a new Transport reference
wiretap
(String
the logger category
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.

public T

Returns:

a new Transport reference
wiretap
(String
the logger category
category
,
LogLevel
the logger level
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.

public final T

Returns:

a new Transport reference
wiretap
(String
the logger category
category
,
LogLevel
the logger level
level
,
AdvancedByteBufFormat
the ByteBuf format
format
)

Apply a wire logger configuration using the specified category (logger), logger level and ByteBuf format.

public final T

Returns:

a new Transport reference
wiretap
(String
the logger category
category
,
LogLevel
the logger level
level
,
AdvancedByteBufFormat
the ByteBuf format
format
,
Charset
the charset
charset
)

Apply a wire logger configuration using the specific category (logger), logger level, ByteBuf format and charset.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

logback to summary
pack-priv static final Logger log

Constructor Detail

Transportback to summary
public Transport()

Method Detail

attrback to summary
public <A> T attr(AttributeKey<A> key, A value)

Update the given attribute key or remove it if the value is null.

Parameters
<A>
the attribute type
key:AttributeKey<A>

the AttributeKey key

value:A

the AttributeKey value

Returns:T

a new Transport reference

bindAddressback to summary
public T bindAddress(Supplier<? extends SocketAddress> bindAddressSupplier)

Set a new local address to which this transport should bind on subscribe.

Parameters
bindAddressSupplier:Supplier<? extends SocketAddress>

A supplier of the address to bind to.

Returns:T

a new Transport

channelGroupback to summary
public T channelGroup(ChannelGroup channelGroup)

Provide a 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.

Parameters
channelGroup:ChannelGroup

a ChannelGroup

Returns:T

a new Transport reference

configurationback to summary
public abstract C configuration()

Return a TransportConfig.

Returns:C

a TransportConfig

doOnChannelInitback to summary
public T doOnChannelInit(ChannelPipelineConfigurer doOnChannelInit)

Configure the channel pipeline while initializing the channel.

Parameters
doOnChannelInit:ChannelPipelineConfigurer

configure the channel pipeline while initializing the channel

Returns:T

a new Transport reference

duplicateback to summary
protected abstract T duplicate()

Return a new Transport inheriting the current configuration. This is a shallow copy.

Returns:T

a new Transport inheriting the current configuration

metricsback to summary
protected T metrics(boolean enable)

Whether to enable metrics to be collected and registered in Micrometer's 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.

Parameters
enable:boolean

true enables metrics collection; false disables it

Returns:T

a new Transport reference

metricsback to summary
public T metrics(boolean enable, Supplier<? extends ChannelMetricsRecorder> recorder)

Specifies whether the metrics are enabled on the 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).

Parameters
enable:boolean

if true enables the metrics on the Transport.

recorder:Supplier<? extends ChannelMetricsRecorder>

a supplier for the ChannelMetricsRecorder

Returns:T

a new Transport reference

observeback to summary
public T observe(ConnectionObserver observer)

Set or add the given ConnectionObserver to observe the connection state changes.

Parameters
observer:ConnectionObserver

the ConnectionObserver to be set or add

Returns:T

a new Transport reference

optionback to summary
public <O> T option(ChannelOption<O> key, O value)

Update the given option key or remove it if the value is null.

Note

Setting ChannelOption#AUTO_READ option will be ignored. It is configured to be false.

Parameters
<O>
the option type
key:ChannelOption<O>

the ChannelOption key

value:O

the ChannelOption value or null

Returns:T

a new Transport reference

Annotations
@SuppressWarnings:ReferenceEquality
runOnback to summary
public T runOn(EventLoopGroup eventLoopGroup)

Run IO loops on the given EventLoopGroup.

Parameters
eventLoopGroup:EventLoopGroup

an eventLoopGroup to share

Returns:T

a new Transport reference

runOnback to summary
public T runOn(LoopResources channelResources)

Run IO loops on a supplied EventLoopGroup from the LoopResources container. Will prefer native (epoll/kqueue) implementation if available unless the environment property reactor.netty.native is set to false.

Parameters
channelResources:LoopResources

a LoopResources accepting native runtime expectation and returning an eventLoopGroup

Returns:T

a new Transport reference

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

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

wiretapback to summary
public 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.

Parameters
enable:boolean

specifies whether the wire logger configuration will be added to the pipeline

Returns:T

a new Transport reference

wiretapback to summary
public 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.

Parameters
category:String

the logger category

Returns:T

a new Transport reference

wiretapback to summary
public 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.

Parameters
category:String

the logger category

level:LogLevel

the logger level

Returns:T

a new Transport reference

wiretapback to summary
public final T wiretap(String category, LogLevel level, AdvancedByteBufFormat format)

Apply a wire logger configuration using the specified category (logger), logger level and ByteBuf format. Depending on the format:

When AdvancedByteBufFormat#TEXTUAL is specified, Charset#defaultCharset() will be used.
Parameters
category:String

the logger category

level:LogLevel

the logger level

format:AdvancedByteBufFormat

the ByteBuf format

Returns:T

a new Transport reference

wiretapback to summary
public final 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. The charset is relevant in case of AdvancedByteBufFormat#TEXTUAL and a different charset than Charset#defaultCharset() is required. Depending on the format:

Parameters
category:String

the logger category

level:LogLevel

the logger level

format:AdvancedByteBufFormat

the ByteBuf format

charset:Charset

the charset

Returns:T

a new Transport reference