Class NettyChannelListenableAsyncCloseable
java.lang.Object
io.servicetalk.transport.netty.internal.NettyChannelListenableAsyncCloseable
- All Implemented Interfaces:
AsyncCloseable
,ListenableAsyncCloseable
- Direct Known Subclasses:
DefaultNettyConnection
Implements
ListenableAsyncCloseable
using a netty Channel
.-
Constructor Summary
ConstructorsConstructorDescriptionNettyChannelListenableAsyncCloseable
(io.netty.channel.Channel channel, Executor offloadingExecutor) New instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected final io.netty.channel.Channel
channel()
Get access to the underlyingChannel
.final Completable
Used to close/shutdown a resource.final Completable
Used to close/shutdown a resource, similar toAsyncCloseable.closeAsync()
, but attempts to cleanup state before abruptly closing.final Completable
final Completable
protected void
Initiate graceful closure.protected final void
Used to notify onClosing ASAP to notify the LoadBalancer to stop using the connection.final Completable
onClose()
Returns aCompletable
that is notified once theListenableAsyncCloseable
was closed.final Completable
Returns aCompletable
that notifies when the connection has begun its closing sequence.
-
Constructor Details
-
NettyChannelListenableAsyncCloseable
public NettyChannelListenableAsyncCloseable(io.netty.channel.Channel channel, Executor offloadingExecutor) New instance.- Parameters:
channel
- to use.offloadingExecutor
-Executor
used to offload any signals to any asynchronous created by thisNettyChannelListenableAsyncCloseable
which could interact with the EventLoop. ProvidingExecutors.immediate()
will result in no offloading.
-
-
Method Details
-
notifyOnClosing
protected final void notifyOnClosing()Used to notify onClosing ASAP to notify the LoadBalancer to stop using the connection. -
onClosing
Returns aCompletable
that notifies when the connection has begun its closing sequence.Note:The
Completable
is not required to be blocking-safe and should be offloaded if theCompletableSource.Subscriber
may block.- Specified by:
onClosing
in interfaceListenableAsyncCloseable
- Returns:
- a
Completable
that notifies when the connection has begun its closing sequence.
-
closeAsync
Description copied from interface:AsyncCloseable
Used to close/shutdown a resource.- Specified by:
closeAsync
in interfaceAsyncCloseable
- Returns:
- A
Completable
that is notified once the close is complete.
-
closeAsyncGracefully
Description copied from interface:AsyncCloseable
Used to close/shutdown a resource, similar toAsyncCloseable.closeAsync()
, but attempts to cleanup state before abruptly closing. This provides a hint that implementations can use to stop accepting new work and finish in flight work. This method is implemented on a "best effort" basis and may be equivalent toAsyncCloseable.closeAsync()
.Note: Implementations may or may not apply a timeout for this operation to complete, if a caller does not want to wait indefinitely, and are unsure if the implementation applies a timeout, it is advisable to apply a timeout and force a call to
AsyncCloseable.closeAsync()
.- Specified by:
closeAsyncGracefully
in interfaceAsyncCloseable
- Returns:
- A
Completable
that is notified once the close is complete.
-
closeAsyncNoOffload
-
closeAsyncGracefullyNoOffload
-
onClose
Description copied from interface:ListenableAsyncCloseable
Returns aCompletable
that is notified once theListenableAsyncCloseable
was closed.- Specified by:
onClose
in interfaceListenableAsyncCloseable
- Returns:
- the
Completable
that is notified on close.
-
channel
protected final io.netty.channel.Channel channel()Get access to the underlyingChannel
.- Returns:
- the underlying
Channel
.
-
doCloseAsyncGracefully
protected void doCloseAsyncGracefully()Initiate graceful closure.
-