@FunctionalInterface public interface Connection extends DisposableChannel
Channel
Disposable.Composite, Disposable.Swap
Modifier and Type | Method and Description |
---|---|
default Connection |
addHandler(ChannelHandler handler)
Add a
ChannelHandler with addHandlerFirst(io.netty.channel.ChannelHandler) if of type of
ChannelOutboundHandler otherwise with
addHandlerLast(io.netty.channel.ChannelHandler) . |
default Connection |
addHandler(String name,
ChannelHandler handler)
Add a
ChannelHandler with addHandlerFirst(io.netty.channel.ChannelHandler) if of type of
ChannelOutboundHandler otherwise with
addHandlerLast(io.netty.channel.ChannelHandler) . |
default Connection |
addHandlerFirst(ChannelHandler handler)
Add a
ChannelHandler to the beginning of the "user" ChannelPipeline ,
that is just after the reactor-added codecs. |
default Connection |
addHandlerFirst(String name,
ChannelHandler handler)
Add a
ChannelHandler to the beginning of the "user" ChannelPipeline ,
that is just after the reactor-added codecs. |
default Connection |
addHandlerLast(ChannelHandler handler)
Add a
ChannelHandler to the end of the "user" ChannelPipeline ,
that is just before the reactor-added handlers (like NettyPipeline.ReactiveBridge . |
default Connection |
addHandlerLast(String name,
ChannelHandler handler)
Add a
ChannelHandler to the end of the "user" ChannelPipeline ,
that is just before the reactor-added handlers (like NettyPipeline.ReactiveBridge . |
default <T extends Connection> |
as(Class<T> clazz)
Return an existing
Connection that must match the given type wrapper or
null. |
default Connection |
bind()
Bind the
Connection to the channel scope via an attribute. |
static Connection |
from(Channel channel)
Return an existing
Connection wrapper or create a simple new one |
default NettyInbound |
inbound()
Return the
NettyInbound read API from this connection. |
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.
|
default Connection |
markPersistent(boolean persist)
Mark the underlying channel as persistent or not.
|
default Connection |
onDispose(Disposable onDispose)
Assigns a
Disposable to be invoked when the channel is closed. |
default Connection |
onReadIdle(long idleTimeout,
Runnable onReadIdle)
Assign a
Runnable to be invoked when reads have become idle for the given
timeout. |
default Mono<Void> |
onTerminate()
Return a Mono succeeding when a
Connection is not used anymore by any
current operations. |
default Connection |
onWriteIdle(long idleTimeout,
Runnable onWriteIdle)
Assign a
Runnable to be invoked when writes have become idle for the given
timeout. |
default NettyOutbound |
outbound()
Return the
NettyOutbound write API from this connection. |
default boolean |
rebind(Connection connection)
Bind a new
Connection 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.
|
address, channel, dispose, disposeNow, disposeNow, disposeSubscriber, isDisposed, onDispose
static Connection from(Channel channel)
Connection
wrapper or create a simple new onechannel
- channel to retrieve the connection reference fromConnection
wrapper or create a simple new one@Nullable default <T extends Connection> T as(Class<T> clazz)
Connection
that must match the given type wrapper or
null.clazz
- connection type to match toConnection
reference or nulldefault Connection addHandler(ChannelHandler handler)
ChannelHandler
with addHandlerFirst(io.netty.channel.ChannelHandler)
if of type of
ChannelOutboundHandler
otherwise with
addHandlerLast(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).
handler
- handler instancedefault Connection addHandler(String name, ChannelHandler handler)
ChannelHandler
with addHandlerFirst(io.netty.channel.ChannelHandler)
if of type of
ChannelOutboundHandler
otherwise with
addHandlerLast(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).
name
- handler namehandler
- handler instancedefault Connection addHandlerLast(ChannelHandler handler)
ChannelHandler
to the end of the "user" ChannelPipeline
,
that is just before the reactor-added handlers (like NettyPipeline.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).
handler
- handler instancedefault Connection addHandlerLast(String name, ChannelHandler handler)
ChannelHandler
to the end of the "user" ChannelPipeline
,
that is just before the reactor-added handlers (like NettyPipeline.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).
name
- handler namehandler
- handler instancedefault Connection addHandlerFirst(ChannelHandler handler)
ChannelHandler
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).
handler
- handler instancedefault Connection addHandlerFirst(String name, ChannelHandler handler)
ChannelHandler
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).
name
- handler namehandler
- handler instancedefault Connection bind()
Connection
to the channel scope via an attribute. Can be
retrieved later by from(io.netty.channel.Channel)
. If a previous reference Connection
was
bound, this instance will take precedence.Connection
.default NettyInbound inbound()
NettyInbound
read API from this connection. If
Connection
has not been configured with a supporting bridge, receive
operations will be unavailable.NettyInbound
read API from this connection.default boolean isPersistent()
Connection
will be disposed on
terminal handler eventdefault Connection markPersistent(boolean persist)
persist
- the boolean flag to mark the Channel
as fully disposable
or reusable when a user handler has terminateddefault Connection onDispose(Disposable onDispose)
DisposableChannel
Disposable
to be invoked when the channel is closed.onDispose
in interface DisposableChannel
onDispose
- the close event handlerdefault Connection onReadIdle(long idleTimeout, Runnable onReadIdle)
Runnable
to be invoked when reads have become idle for the given
timeout. This replaces any previously set idle callback.idleTimeout
- the idle timeoutonReadIdle
- the idle timeout handlerdefault Mono<Void> onTerminate()
Connection
is not used anymore by any
current operations. A typical example is when a pooled connection is released or
an operations bridge has terminated.Connection
has been terminateddefault Connection onWriteIdle(long idleTimeout, Runnable onWriteIdle)
Runnable
to be invoked when writes have become idle for the given
timeout. This replaces any previously set idle callback.idleTimeout
- the idle timeoutonWriteIdle
- the idle timeout handlerdefault NettyOutbound outbound()
NettyOutbound
write API from this connection. If
Connection
has not been configured with a supporting bridge, send
operations will be unavailable.NettyOutbound
read API from this connection.default boolean rebind(@Nullable Connection connection)
Connection
reference or null to the channel
attributes only if this instance is currently bound.connection
- a new connection referencebind()
default Connection removeHandler(String name)
name
- handler namedefault Connection replaceHandler(String name, ChannelHandler handler)
RuntimeException
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.
name
- handler name