Interface Connection
- All Superinterfaces:
Disposable,DisposableChannel
- All Known Subinterfaces:
QuicConnection
- All Known Implementing Classes:
ChannelOperations,HttpOperations
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Channel.- Since:
- 0.8
- Author:
- Stephane Maldini
-
Nested Class Summary
Nested classes/interfaces inherited from interface reactor.core.Disposable
Disposable.Composite, Disposable.Swap -
Method Summary
Modifier and TypeMethodDescriptiondefault ConnectionaddHandler(ChannelHandler handler) Deprecated.as of 1.0.17.default ConnectionaddHandler(String name, ChannelHandler handler) Deprecated.as of 1.0.17.default ConnectionaddHandlerFirst(ChannelHandler handler) Add aChannelHandlerto the beginning of the "user"ChannelPipeline, that is just after the reactor-added codecs.default ConnectionaddHandlerFirst(String name, ChannelHandler handler) Add aChannelHandlerto the beginning of the "user"ChannelPipeline, that is just after the reactor-added codecs.default ConnectionaddHandlerLast(ChannelHandler handler) Add aChannelHandlerto the end of the "user"ChannelPipeline, that is just before the reactor-added handlers likeNettyPipeline.ReactiveBridge.default ConnectionaddHandlerLast(String name, ChannelHandler handler) Add aChannelHandlerto the end of the "user"ChannelPipeline, that is just before the reactor-added handlers likeNettyPipeline.ReactiveBridge.default <T extends Connection>
@Nullable TReturn an existingConnectionthat must match the given type wrapper or null.default Connectionbind()Bind theConnectionto the channel scope via an attribute.static ConnectionReturn an existingConnectionwrapper or create a simple new one.default NettyInboundinbound()Return theNettyInboundread API from this connection.default booleanReturn false if it will force a close on terminal protocol events thus defeating any pooling strategy Return true (default) if it will release on terminal protocol events thus keeping alive the channel if possible.default ConnectionmarkPersistent(boolean persist) Mark the underlying channel as persistent or not.default ConnectiononDispose(Disposable onDispose) Assigns aDisposableto be invoked when the channel is closed.default ConnectiononReadIdle(long idleTimeout, Runnable onReadIdle) Assign aRunnableto be invoked when reads have become idle for the given timeout.Return a Mono succeeding when aConnectionis not used anymore by any current operations.default ConnectiononWriteIdle(long idleTimeout, Runnable onWriteIdle) Assign aRunnableto be invoked when writes have become idle for the given timeout.default NettyOutboundoutbound()Return theNettyOutboundwrite API from this connection.default booleanrebind(@Nullable Connection connection) Bind a newConnectionreference or null to the channel attributes only if this instance is currently bound.default ConnectionremoveHandler(String name) Remove a named handler if present and return this context.default ConnectionreplaceHandler(String name, ChannelHandler handler) Replace a named handler if present and return this context.Methods inherited from interface reactor.netty.DisposableChannel
address, channel, dispose, disposeNow, disposeNow, disposeSubscriber, isDisposed, onDispose
-
Method Details
-
from
Return an existingConnectionwrapper or create a simple new one.- Parameters:
channel- channel to retrieve the connection reference from- Returns:
- an existing
Connectionwrapper or create a simple new one
-
as
Return an existingConnectionthat must match the given type wrapper or null.- Parameters:
clazz- connection type to match to- Returns:
- a matching
Connectionreference or null
-
addHandler
Deprecated.as of 1.0.17. UseaddHandlerFirst(ChannelHandler)oraddHandlerLast(ChannelHandler). This method will be removed in version 1.2.0.Add aChannelHandlerwithaddHandlerFirst(io.netty.channel.ChannelHandler)if of type ofChannelOutboundHandlerotherwise withaddHandlerLast(io.netty.channel.ChannelHandler). Implementation may add more auto handling in particular HTTP based context will prepend an HttpContent body extractor.[ [reactor codecs], [<- user FIRST HANDLERS added here, user LAST HANDLERS added here ->], [reactor handlers] ]If effectively added, the handler will be safely removed when the channel is made inactive (pool release). As the Connection object is available once the channel is in active state, events prior this state will not be available (i.e.
channelRegistered,initChannel,channelActive, etc.)- Parameters:
handler- handler instance- Returns:
- this Connection
-
addHandler
Deprecated.as of 1.0.17. UseaddHandlerFirst(String, ChannelHandler)oraddHandlerLast(String, ChannelHandler). This method will be removed in version 1.2.0.Add aChannelHandlerwithaddHandlerFirst(io.netty.channel.ChannelHandler)if of type ofChannelOutboundHandlerotherwise withaddHandlerLast(io.netty.channel.ChannelHandler). Implementation may add more auto handling in particular HTTP based context will prepend an HttpContent body extractor.[ [reactor codecs], [<- user FIRST HANDLERS added here, user LAST HANDLERS added here ->], [reactor handlers] ]If effectively added, the handler will be safely removed when the channel is made inactive (pool release). As the Connection object is available once the channel is in active state, events prior this state will not be available (i.e.
channelRegistered,initChannel,channelActive, etc.)- Parameters:
name- handler namehandler- handler instance- Returns:
- this Connection
-
addHandlerLast
Add aChannelHandlerto the end of the "user"ChannelPipeline, that is just before the reactor-added handlers likeNettyPipeline.ReactiveBridge. If a handler with a similar name already exists, this operation is skipped.[ [reactor codecs], [<- user FIRST HANDLERS added here, user LAST HANDLERS added here ->], [reactor handlers] ]If effectively added, the handler will be safely removed when the channel is made inactive (pool release). As the Connection object is available once the channel is in active state, events prior this state will not be available (i.e.
channelRegistered,initChannel,channelActive, etc.)- Parameters:
handler- handler instance- Returns:
- this Connection
-
addHandlerLast
Add aChannelHandlerto the end of the "user"ChannelPipeline, that is just before the reactor-added handlers likeNettyPipeline.ReactiveBridge. If a handler with a similar name already exists, this operation is skipped.[ [reactor codecs], [<- user FIRST HANDLERS added here, user LAST HANDLERS added here ->], [reactor handlers] ]If effectively added, the handler will be safely removed when the channel is made inactive (pool release). As the Connection object is available once the channel is in active state, events prior this state will not be available (i.e.
channelRegistered,initChannel,channelActive, etc.)- Parameters:
name- handler namehandler- handler instance- Returns:
- this Connection
-
addHandlerFirst
Add aChannelHandlerto the beginning of the "user"ChannelPipeline, that is just after the reactor-added codecs. If a handler with a similar name already exists, this operation is skipped.[ [reactor codecs], [<- user FIRST HANDLERS added here, user LAST HANDLERS added here ->], [reactor handlers] ].If effectively added, the handler will be safely removed when the channel is made inactive (pool release). As the Connection object is available once the channel is in active state, events prior this state will not be available (i.e.
channelRegistered,initChannel,channelActive, etc.)- Parameters:
handler- handler instance- Returns:
- this Connection
-
addHandlerFirst
Add aChannelHandlerto the beginning of the "user"ChannelPipeline, that is just after the reactor-added codecs. If a handler with a similar name already exists, this operation is skipped.[ [reactor codecs], [<- user FIRST HANDLERS added here, user LAST HANDLERS added here ->], [reactor handlers] ]If effectively added, the handler will be safely removed when the channel is made inactive (pool release). As the Connection object is available once the channel is in active state, events prior this state will not be available (i.e.
channelRegistered,initChannel,channelActive, etc.)- Parameters:
name- handler namehandler- handler instance- Returns:
- this Connection
-
bind
Bind theConnectionto the channel scope via an attribute. Can be retrieved later byfrom(io.netty.channel.Channel). If a previous referenceConnectionwas bound, this instance will take precedence.- Returns:
- this
Connection.
-
inbound
Return theNettyInboundread API from this connection. IfConnectionhas not been configured with a supporting bridge, receive operations will be unavailable.- Returns:
- the
NettyInboundread API from this connection.
-
isPersistent
default boolean isPersistent()Return false if it will force a close on terminal protocol events thus defeating any pooling strategy Return true (default) if it will release on terminal protocol events thus keeping alive the channel if possible.- Returns:
- whether the underlying
Connectionwill be disposed on terminal handler event
-
markPersistent
Mark the underlying channel as persistent or not. If false, it will force a close on terminal protocol events thus defeating any pooling strategy if true (default), it will release on terminal protocol events thus keeping alive the channel if possible.- Parameters:
persist- the boolean flag to mark theChannelas fully disposable or reusable when a user handler has terminated- Returns:
- this Connection
-
onDispose
Description copied from interface:DisposableChannelAssigns aDisposableto be invoked when the channel is closed.- Specified by:
onDisposein interfaceDisposableChannel- Parameters:
onDispose- the close event handler- Returns:
- this
-
onReadIdle
Assign aRunnableto be invoked when reads have become idle for the given timeout. This replaces any previously set idle callback.- Parameters:
idleTimeout- the idle timeoutonReadIdle- the idle timeout handler- Returns:
- this
-
onTerminate
Return a Mono succeeding when aConnectionis not used anymore by any current operations. A typical example is when a pooled connection is released or an operations bridge has terminated.- Returns:
- a Mono succeeding when a
Connectionhas been terminated
-
onWriteIdle
Assign aRunnableto be invoked when writes have become idle for the given timeout. This replaces any previously set idle callback.- Parameters:
idleTimeout- the idle timeoutonWriteIdle- the idle timeout handler- Returns:
- this
-
outbound
Return theNettyOutboundwrite API from this connection. IfConnectionhas not been configured with a supporting bridge, send operations will be unavailable.- Returns:
- the
NettyOutboundread API from this connection.
-
rebind
Bind a newConnectionreference or null to the channel attributes only if this instance is currently bound.- Parameters:
connection- a new connection reference- Returns:
- true if bound
- See Also:
-
removeHandler
Remove a named handler if present and return this context.- Parameters:
name- handler name- Returns:
- this Connection
-
replaceHandler
Replace a named handler if present and return this context. If handler wasn't present, anRuntimeExceptionwill be thrown.Note: if the new handler is of different type, dependent handling like the "extractor" introduced via HTTP-based
addHandler(io.netty.channel.ChannelHandler)might not expect/support the new messages type.- Parameters:
name- handler name- Returns:
- this Connection
-