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 Connection
addHandler
(ChannelHandler handler) Deprecated.as of 1.0.17.default Connection
addHandler
(String name, ChannelHandler handler) Deprecated.as of 1.0.17.default Connection
addHandlerFirst
(ChannelHandler handler) Add aChannelHandler
to the beginning of the "user"ChannelPipeline
, that is just after the reactor-added codecs.default Connection
addHandlerFirst
(String name, ChannelHandler handler) Add aChannelHandler
to the beginning of the "user"ChannelPipeline
, that is just after the reactor-added codecs.default Connection
addHandlerLast
(ChannelHandler handler) Add aChannelHandler
to the end of the "user"ChannelPipeline
, that is just before the reactor-added handlers likeNettyPipeline.ReactiveBridge
.default Connection
addHandlerLast
(String name, ChannelHandler handler) Add aChannelHandler
to the end of the "user"ChannelPipeline
, that is just before the reactor-added handlers likeNettyPipeline.ReactiveBridge
.default <T extends Connection>
@Nullable TReturn an existingConnection
that must match the given type wrapper or null.default Connection
bind()
Bind theConnection
to the channel scope via an attribute.static Connection
Return an existingConnection
wrapper or create a simple new one.default NettyInbound
inbound()
Return theNettyInbound
read API from this connection.default boolean
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.default Connection
markPersistent
(boolean persist) Mark the underlying channel as persistent or not.default Connection
onDispose
(Disposable onDispose) Assigns aDisposable
to be invoked when the channel is closed.default Connection
onReadIdle
(long idleTimeout, Runnable onReadIdle) Assign aRunnable
to be invoked when reads have become idle for the given timeout.Return a Mono succeeding when aConnection
is not used anymore by any current operations.default Connection
onWriteIdle
(long idleTimeout, Runnable onWriteIdle) Assign aRunnable
to be invoked when writes have become idle for the given timeout.default NettyOutbound
outbound()
Return theNettyOutbound
write API from this connection.default boolean
rebind
(@Nullable Connection connection) Bind a newConnection
reference or null to the channel attributes only if this instance is currently bound.default Connection
removeHandler
(String name) Remove a named handler if present and return this context.default Connection
replaceHandler
(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 existingConnection
wrapper or create a simple new one.- Parameters:
channel
- channel to retrieve the connection reference from- Returns:
- an existing
Connection
wrapper or create a simple new one
-
as
Return an existingConnection
that must match the given type wrapper or null.- Parameters:
clazz
- connection type to match to- Returns:
- a matching
Connection
reference or null
-
addHandler
Deprecated.as of 1.0.17. UseaddHandlerFirst(ChannelHandler)
oraddHandlerLast(ChannelHandler)
. This method will be removed in version 1.2.0.Add aChannelHandler
withaddHandlerFirst(io.netty.channel.ChannelHandler)
if of type ofChannelOutboundHandler
otherwise 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 aChannelHandler
withaddHandlerFirst(io.netty.channel.ChannelHandler)
if of type ofChannelOutboundHandler
otherwise 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 aChannelHandler
to 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 aChannelHandler
to 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 aChannelHandler
to 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 aChannelHandler
to 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 theConnection
to the channel scope via an attribute. Can be retrieved later byfrom(io.netty.channel.Channel)
. If a previous referenceConnection
was bound, this instance will take precedence.- Returns:
- this
Connection
.
-
inbound
Return theNettyInbound
read API from this connection. IfConnection
has not been configured with a supporting bridge, receive operations will be unavailable.- Returns:
- the
NettyInbound
read 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
Connection
will 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 theChannel
as fully disposable or reusable when a user handler has terminated- Returns:
- this Connection
-
onDispose
Description copied from interface:DisposableChannel
Assigns aDisposable
to be invoked when the channel is closed.- Specified by:
onDispose
in interfaceDisposableChannel
- Parameters:
onDispose
- the close event handler- Returns:
- this
-
onReadIdle
Assign aRunnable
to 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 aConnection
is 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
Connection
has been terminated
-
onWriteIdle
Assign aRunnable
to 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 theNettyOutbound
write API from this connection. IfConnection
has not been configured with a supporting bridge, send operations will be unavailable.- Returns:
- the
NettyOutbound
read API from this connection.
-
rebind
Bind a newConnection
reference 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, anRuntimeException
will 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
-