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
ServerContextimplementation using a nettyChannel.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletablecloseAsync()Used to close/shutdown a resource.CompletablecloseAsyncGracefully()Used to close/shutdown a resource, similar toAsyncCloseable.closeAsync(), but attempts to cleanup state before abruptly closing.ExecutionContextexecutionContext()ReturnsExecutionContextused by this server.java.net.SocketAddresslistenAddress()Listen address for the server associated with this context.CompletableonClose()Returns aCompletablethat is notified once theListenableAsyncCloseablewas closed.static ServerContextwrap(io.netty.channel.Channel listenChannel, ListenableAsyncCloseable channelSetCloseable, AsyncCloseable closeBefore, ExecutionContext executionContext)Wrap the passedNettyServerContext.static ServerContextwrap(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-NettyServerContextto wrap.closeBefore-Completablewhich needs to be closed first beforetoWrapwill be closed.- Returns:
- A new
NettyServerContextinstance.
-
wrap
public static ServerContext wrap(io.netty.channel.Channel listenChannel, ListenableAsyncCloseable channelSetCloseable, @Nullable AsyncCloseable closeBefore, ExecutionContext executionContext)
Wrap the passedNettyServerContext.- Parameters:
listenChannel-Channelto wrap.channelSetCloseable-ChannelSetto wrap.closeBefore-Completablewhich needs to closed first beforelistenChannelwill be closed.executionContext-ExecutionContextused by this server.- Returns:
- A new
NettyServerContextinstance.
-
listenAddress
public java.net.SocketAddress listenAddress()
Description copied from interface:ServerContextListen address for the server associated with this context.- Specified by:
listenAddressin interfaceServerContext- Returns:
- Address which the associated server is listening at.
-
executionContext
public ExecutionContext executionContext()
Description copied from interface:ServerContextReturnsExecutionContextused by this server.- Specified by:
executionContextin interfaceServerContext- Returns:
ExecutionContextused by this server.
-
closeAsync
public Completable closeAsync()
Description copied from interface:AsyncCloseableUsed to close/shutdown a resource.- Specified by:
closeAsyncin interfaceAsyncCloseable- Returns:
- A
Completablethat is notified once the close is complete.
-
closeAsyncGracefully
public Completable closeAsyncGracefully()
Description copied from interface:AsyncCloseableUsed 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:
closeAsyncGracefullyin interfaceAsyncCloseable- Returns:
- A
Completablethat is notified once the close is complete.
-
onClose
public Completable onClose()
Description copied from interface:ListenableAsyncCloseableReturns aCompletablethat is notified once theListenableAsyncCloseablewas closed.- Specified by:
onClosein interfaceListenableAsyncCloseable- Returns:
- the
Completablethat is notified on close.
-
-