Package reactor.netty.transport
Class Transport<T extends Transport<T,C>,C extends TransportConfig>
java.lang.Object
reactor.netty.transport.Transport<T,C>
- Type Parameters:
T- Transport implementationC- Transport Config implementation
- Direct Known Subclasses:
ClientTransport,QuicClient,QuicServer,ServerTransport,UdpServer
An immutable transport builder for clients and servers.
- Since:
- 1.0.0
- Author:
- Stephane Maldini, Violeta Georgieva
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<A> Tattr(AttributeKey<A> key, @Nullable A value) Update the given attribute key or remove it if the value is null.bindAddress(Supplier<? extends SocketAddress> bindAddressSupplier) Set a new local address to which this transport should bind on subscribe.channelGroup(ChannelGroup channelGroup) Provide aChannelGroupto hold all active connected channels.abstract CReturn aTransportConfig.doOnChannelInit(ChannelPipelineConfigurer doOnChannelInit) Configure the channel pipeline while initializing the channel.protected abstract TReturn a newTransportinheriting the current configuration.protected Tmetrics(boolean enable) Whether to enable metrics to be collected and registered in Micrometer'sglobalRegistry.metrics(boolean enable, Supplier<? extends ChannelMetricsRecorder> recorder) Specifies whether the metrics are enabled on theTransport.observe(ConnectionObserver observer) Set or add the givenConnectionObserverto observe the connection state changes.<O> Toption(ChannelOption<O> key, @Nullable O value) Update the given option key or remove it if the value is null.runOn(EventLoopGroup eventLoopGroup) Run IO loops on the givenEventLoopGroup.runOn(LoopResources channelResources) Run IO loops on a suppliedEventLoopGroupfrom theLoopResourcescontainer.runOn(LoopResources loopResources, boolean preferNative) Run IO loops on a suppliedEventLoopGroupfrom theLoopResourcescontainer.wiretap(boolean enable) Apply or remove a wire logger configuration usingTransportcategory (logger),DEBUGlogger level andAdvancedByteBufFormat.HEX_DUMPforByteBufformat, which means both events and content will be logged and the content will be in hex format.Apply a wire logger configuration using the specified category (logger),DEBUGlogger level andAdvancedByteBufFormat.HEX_DUMPforByteBufformat, which means both events and content will be logged and the content will be in hex format.Apply a wire logger configuration using the specified category (logger), logger level andAdvancedByteBufFormat.HEX_DUMPforByteBufformat, which means both events and content will be logged and the content will be in hex format.final Twiretap(String category, LogLevel level, AdvancedByteBufFormat format) Apply a wire logger configuration using the specified category (logger), logger level andByteBufformat.final Twiretap(String category, LogLevel level, AdvancedByteBufFormat format, Charset charset) Apply a wire logger configuration using the specific category (logger), logger level,ByteBufformat and charset.
-
Constructor Details
-
Transport
public Transport()
-
-
Method Details
-
attr
Update the given attribute key or remove it if the value is null.- Type Parameters:
A- the attribute type- Parameters:
key- theAttributeKeykeyvalue- theAttributeKeyvalue- Returns:
- a new
Transportreference
-
bindAddress
Set a new local address to which this transport should bind on subscribe.- Parameters:
bindAddressSupplier- A supplier of the address to bind to.- Returns:
- a new
Transport
-
channelGroup
Provide aChannelGroupto hold all active connected channels.Graceful Shutdown:
When a
ChannelGroupis set, calls toDisposableChannel.disposeNow()andDisposableChannel.disposeNow(Duration)not only stop accepting new requests but also additionally wait for all active requests, in theChannelGroup, to complete, within the given timeout.- Parameters:
channelGroup- aChannelGroup- Returns:
- a new
Transportreference
-
configuration
Return aTransportConfig.- Returns:
- a
TransportConfig
-
doOnChannelInit
Configure the channel pipeline while initializing the channel.- Parameters:
doOnChannelInit- configure the channel pipeline while initializing the channel- Returns:
- a new
Transportreference
-
metrics
Whether to enable metrics to be collected and registered in Micrometer'sglobalRegistry. Applications can separately register their ownfilters. 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- true enables metrics collection; false disables it- Returns:
- a new
Transportreference
-
metrics
Specifies whether the metrics are enabled on theTransport. 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 theTransport).- Parameters:
enable- if true enables the metrics on theTransport.recorder- a supplier for theChannelMetricsRecorder- Returns:
- a new
Transportreference
-
observe
Set or add the givenConnectionObserverto observe the connection state changes.- Parameters:
observer- theConnectionObserverto be set or add- Returns:
- a new
Transportreference
-
option
Update the given option key or remove it if the value is null. Note: SettingChannelOption.AUTO_READoption will be ignored. It is configured to befalse.- Type Parameters:
O- the option type- Parameters:
key- theChannelOptionkeyvalue- theChannelOptionvalue or null- Returns:
- a new
Transportreference
-
runOn
Run IO loops on the givenEventLoopGroup.- Parameters:
eventLoopGroup- an eventLoopGroup to share- Returns:
- a new
Transportreference
-
runOn
Run IO loops on a suppliedEventLoopGroupfrom theLoopResourcescontainer. Will prefer native (epoll/io_uring/kqueue) implementation if available unless the environment propertyreactor.netty.nativeis set tofalse.- Parameters:
channelResources- aLoopResourcesaccepting native runtime expectation and returning an eventLoopGroup- Returns:
- a new
Transportreference
-
runOn
Run IO loops on a suppliedEventLoopGroupfrom theLoopResourcescontainer.- Parameters:
loopResources- a new loop resourcespreferNative- should prefer running on epoll, io_uring, kqueue or similar instead of java NIO- Returns:
- a new
Transportreference
-
wiretap
Apply or remove a wire logger configuration usingTransportcategory (logger),DEBUGlogger level andAdvancedByteBufFormat.HEX_DUMPforByteBufformat, which means both events and content will be logged and the content will be in hex format.- Parameters:
enable- specifies whether the wire logger configuration will be added to the pipeline- Returns:
- a new
Transportreference
-
wiretap
Apply a wire logger configuration using the specified category (logger),DEBUGlogger level andAdvancedByteBufFormat.HEX_DUMPforByteBufformat, which means both events and content will be logged and the content will be in hex format.- Parameters:
category- the logger category- Returns:
- a new
Transportreference
-
wiretap
Apply a wire logger configuration using the specified category (logger), logger level andAdvancedByteBufFormat.HEX_DUMPforByteBufformat, which means both events and content will be logged and the content will be in hex format.- Parameters:
category- the logger categorylevel- the logger level- Returns:
- a new
Transportreference
-
wiretap
Apply a wire logger configuration using the specified category (logger), logger level andByteBufformat. 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
AdvancedByteBufFormat.TEXTUALis specified,Charset.defaultCharset()will be used. -
wiretap
public final T wiretap(String category, LogLevel level, AdvancedByteBufFormat format, Charset charset) Apply a wire logger configuration using the specific category (logger), logger level,ByteBufformat and charset. The charset is relevant in case ofAdvancedByteBufFormat.TEXTUALand a different charset thanCharset.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
-
duplicate
Return a newTransportinheriting the current configuration. This is a shallow copy.- Returns:
- a new
Transportinheriting the current configuration
-