Class CloseHandler
java.lang.Object
io.servicetalk.transport.netty.internal.CloseHandler
Contract between protocol codecs and a close handler.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
These events indicate an event was observed from the protocol orChannel
that indicates the end of theChannel
and no further requests should be attempted.static final class
ClosedChannelException
with additional meta-data to provide more context on what side initiated the close event.static final class
Netty UserEvent to indicate the further inbound data should be discarded.static final class
CloseHandler.NettyUserEvent
to indicate the end of inbound data was observed at the transport. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CloseHandler
forNonPipelined
(boolean isClient, io.netty.channel.ChannelConfig config) Create a newCloseHandler
instance which doesn't support pipelining, and only ever has a single outstanding request/response.static CloseHandler
forPipelinedRequestResponse
(boolean client, io.netty.channel.ChannelConfig config) NewCloseHandler
instance.abstract void
protocolClosingInbound
(io.netty.channel.ChannelHandlerContext ctx) Signal inbound close command observed, to be emitted from theEventLoop
for theChannel
.abstract void
protocolClosingOutbound
(io.netty.channel.ChannelHandlerContext ctx) Signal outbound close command observed, to be emitted from theEventLoop
for theChannel
.abstract void
protocolPayloadBeginInbound
(io.netty.channel.ChannelHandlerContext ctx) Signal begin of inbound payload, to be emitted from theEventLoop
for theChannel
.abstract void
protocolPayloadBeginOutbound
(io.netty.channel.ChannelHandlerContext ctx) Signal begin of outbound payload, to be emitted from theEventLoop
for theChannel
.abstract void
protocolPayloadEndInbound
(io.netty.channel.ChannelHandlerContext ctx) Signal end of inbound payload, to be emitted from theEventLoop
for theChannel
.abstract void
protocolPayloadEndOutbound
(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise) Signal end of outbound payload, including theChannelPromise
associated with the last write.
-
Field Details
-
UNSUPPORTED_PROTOCOL_CLOSE_HANDLER
-
-
Constructor Details
-
CloseHandler
public CloseHandler()
-
-
Method Details
-
forPipelinedRequestResponse
public static CloseHandler forPipelinedRequestResponse(boolean client, io.netty.channel.ChannelConfig config) NewCloseHandler
instance.- Parameters:
client
- operation mode,TRUE
forclient
orFALSE
forserver
config
- TheChannelConfig
associated with the channel to create theCloseHandler
for. ThisChannelConfig
maybe modified to ensure the underlying options allow for half-closure.- Returns:
- a new connection close handler with behavior for a pipelined request/response client or server
-
forNonPipelined
Create a newCloseHandler
instance which doesn't support pipelining, and only ever has a single outstanding request/response. TheCloseHandler
doesn't require the channel be of any special type (e.g.DuplexChannel
) nor support any special channel options (e.g.ChannelOption.ALLOW_HALF_CLOSURE
).- Parameters:
isClient
- operation mode,TRUE
forclient
orFALSE
forserver
.config
- TheChannelConfig
associated with the channel to create theCloseHandler
for.- Returns:
- a new
CloseHandler
instance which doesn't support pipelining.
-
protocolPayloadBeginInbound
public abstract void protocolPayloadBeginInbound(io.netty.channel.ChannelHandlerContext ctx) Signal begin of inbound payload, to be emitted from theEventLoop
for theChannel
.- Parameters:
ctx
-ChannelHandlerContext
-
protocolPayloadEndInbound
public abstract void protocolPayloadEndInbound(io.netty.channel.ChannelHandlerContext ctx) Signal end of inbound payload, to be emitted from theEventLoop
for theChannel
.- Parameters:
ctx
-ChannelHandlerContext
-
protocolPayloadBeginOutbound
public abstract void protocolPayloadBeginOutbound(io.netty.channel.ChannelHandlerContext ctx) Signal begin of outbound payload, to be emitted from theEventLoop
for theChannel
.- Parameters:
ctx
-ChannelHandlerContext
-
protocolPayloadEndOutbound
public abstract void protocolPayloadEndOutbound(io.netty.channel.ChannelHandlerContext ctx, @Nullable io.netty.channel.ChannelPromise promise) Signal end of outbound payload, including theChannelPromise
associated with the last write. Must be called from theEventLoop
for theChannel
.- Parameters:
promise
- TheChannelPromise
associated with the last write operation ornull
if payload ends without a write operation (aborted/cancelled).ctx
-ChannelHandlerContext
-
protocolClosingInbound
public abstract void protocolClosingInbound(io.netty.channel.ChannelHandlerContext ctx) Signal inbound close command observed, to be emitted from theEventLoop
for theChannel
.- Parameters:
ctx
-ChannelHandlerContext
-
protocolClosingOutbound
public abstract void protocolClosingOutbound(io.netty.channel.ChannelHandlerContext ctx) Signal outbound close command observed, to be emitted from theEventLoop
for theChannel
.- Parameters:
ctx
-ChannelHandlerContext
-