public final class NettyServerContext extends java.lang.Object implements ServerContext
ServerContext implementation using a netty Channel.| Modifier and Type | Method and Description |
|---|---|
Completable |
closeAsync()
Used to close/shutdown a resource.
|
Completable |
closeAsyncGracefully()
Used to close/shutdown a resource, similar to
AsyncCloseable.closeAsync(), but attempts to cleanup state before
abruptly closing. |
ExecutionContext |
executionContext()
Returns
ExecutionContext used by this server. |
java.net.SocketAddress |
listenAddress()
Listen address for the server associated with this context.
|
Completable |
onClose()
Returns a
Completable that is notified once the ListenableAsyncCloseable was closed. |
static ServerContext |
wrap(io.netty.channel.Channel listenChannel,
ListenableAsyncCloseable channelSetCloseable,
AsyncCloseable closeBefore,
ExecutionContext executionContext)
Wrap the passed
NettyServerContext. |
static ServerContext |
wrap(NettyServerContext toWrap,
AsyncCloseable closeBefore)
Wrap the passed
NettyServerContext. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitawaitShutdown, close, closeGracefullypublic static ServerContext wrap(NettyServerContext toWrap, AsyncCloseable closeBefore)
NettyServerContext.toWrap - NettyServerContext to wrap.closeBefore - Completable which needs to be closed first before toWrap will be closed.NettyServerContext instance.public static ServerContext wrap(io.netty.channel.Channel listenChannel, ListenableAsyncCloseable channelSetCloseable, @Nullable AsyncCloseable closeBefore, ExecutionContext executionContext)
NettyServerContext.listenChannel - Channel to wrap.channelSetCloseable - ChannelSet to wrap.closeBefore - Completable which needs to closed first before listenChannel will be closed.executionContext - ExecutionContext used by this server.NettyServerContext instance.public java.net.SocketAddress listenAddress()
ServerContextlistenAddress in interface ServerContextpublic ExecutionContext executionContext()
ServerContextExecutionContext used by this server.executionContext in interface ServerContextExecutionContext used by this server.public Completable closeAsync()
AsyncCloseablecloseAsync in interface AsyncCloseableCompletableSource that is notified once the close is complete.public Completable closeAsyncGracefully()
AsyncCloseableAsyncCloseable.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().
closeAsyncGracefully in interface AsyncCloseableCompletable that is notified once the close is complete.public Completable onClose()
ListenableAsyncCloseableCompletable that is notified once the ListenableAsyncCloseable was closed.onClose in interface ListenableAsyncCloseableCompletable that is notified on close.