Class NettyServerContext
- java.lang.Object
-
- io.servicetalk.transport.netty.internal.NettyServerContext
-
- All Implemented Interfaces:
AsyncCloseable
,ListenableAsyncCloseable
,GracefulAutoCloseable
,ServerContext
,java.lang.AutoCloseable
public final class NettyServerContext extends java.lang.Object implements ServerContext
ServerContext
implementation using a nettyChannel
.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Completable
closeAsync()
Used to close/shutdown a resource.Completable
closeAsyncGracefully()
Used to close/shutdown a resource, similar toAsyncCloseable.closeAsync()
, but attempts to cleanup state before abruptly closing.ExecutionContext
executionContext()
ReturnsExecutionContext
used by this server.java.net.SocketAddress
listenAddress()
Listen address for the server associated with this context.Completable
onClose()
Returns aCompletable
that is notified once theListenableAsyncCloseable
was closed.static ServerContext
wrap(io.netty.channel.Channel listenChannel, ListenableAsyncCloseable channelSetCloseable, AsyncCloseable closeBefore, ExecutionContext executionContext)
Wrap the passedNettyServerContext
.static ServerContext
wrap(NettyServerContext toWrap, AsyncCloseable closeBefore)
Wrap the passedNettyServerContext
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.servicetalk.transport.api.ServerContext
awaitShutdown, close, closeGracefully
-
-
-
-
Method Detail
-
wrap
public static ServerContext wrap(NettyServerContext toWrap, AsyncCloseable closeBefore)
Wrap the passedNettyServerContext
.- Parameters:
toWrap
-NettyServerContext
to wrap.closeBefore
-Completable
which needs to be closed first beforetoWrap
will be closed.- Returns:
- A new
NettyServerContext
instance.
-
wrap
public static ServerContext wrap(io.netty.channel.Channel listenChannel, ListenableAsyncCloseable channelSetCloseable, @Nullable AsyncCloseable closeBefore, ExecutionContext executionContext)
Wrap the passedNettyServerContext
.- Parameters:
listenChannel
-Channel
to wrap.channelSetCloseable
-ChannelSet
to wrap.closeBefore
-Completable
which needs to closed first beforelistenChannel
will be closed.executionContext
-ExecutionContext
used by this server.- Returns:
- A new
NettyServerContext
instance.
-
listenAddress
public java.net.SocketAddress listenAddress()
Description copied from interface:ServerContext
Listen address for the server associated with this context.- Specified by:
listenAddress
in interfaceServerContext
- Returns:
- Address which the associated server is listening at.
-
executionContext
public ExecutionContext executionContext()
Description copied from interface:ServerContext
ReturnsExecutionContext
used by this server.- Specified by:
executionContext
in interfaceServerContext
- Returns:
ExecutionContext
used by this server.
-
closeAsync
public Completable 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
public Completable 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.
-
onClose
public Completable 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.
-
-