Class NettyChannelListenableAsyncCloseable

java.lang.Object
io.servicetalk.transport.netty.internal.NettyChannelListenableAsyncCloseable
All Implemented Interfaces:
AsyncCloseable, ListenableAsyncCloseable
Direct Known Subclasses:
DefaultNettyConnection

public class NettyChannelListenableAsyncCloseable extends Object
Implements ListenableAsyncCloseable using a netty Channel.
  • 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 this NettyChannelListenableAsyncCloseable which could interact with the EventLoop. Providing Executors.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

      public final Completable onClosing()
      Returns a Completable 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 the CompletableSource.Subscriber may block.

      Specified by:
      onClosing in interface ListenableAsyncCloseable
      Returns:
      a Completable that notifies when the connection has begun its closing sequence.
    • closeAsync

      public final Completable closeAsync()
      Description copied from interface: AsyncCloseable
      Used to close/shutdown a resource.
      Specified by:
      closeAsync in interface AsyncCloseable
      Returns:
      A Completable that is notified once the close is complete.
    • closeAsyncGracefully

      public final Completable closeAsyncGracefully()
      Description copied from interface: AsyncCloseable
      Used to close/shutdown a resource, similar to AsyncCloseable.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 to AsyncCloseable.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 interface AsyncCloseable
      Returns:
      A Completable that is notified once the close is complete.
    • closeAsyncNoOffload

      public final Completable closeAsyncNoOffload()
    • closeAsyncGracefullyNoOffload

      public final Completable closeAsyncGracefullyNoOffload()
    • onClose

      public final Completable onClose()
      Description copied from interface: ListenableAsyncCloseable
      Returns a Completable that is notified once the ListenableAsyncCloseable was closed.
      Specified by:
      onClose in interface ListenableAsyncCloseable
      Returns:
      the Completable that is notified on close.
    • channel

      protected final io.netty.channel.Channel channel()
      Get access to the underlying Channel.
      Returns:
      the underlying Channel.
    • doCloseAsyncGracefully

      protected void doCloseAsyncGracefully()
      Initiate graceful closure.