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, wait
awaitShutdown, close, closeGracefully
public 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()
ServerContext
listenAddress
in interface ServerContext
public ExecutionContext executionContext()
ServerContext
ExecutionContext
used by this server.executionContext
in interface ServerContext
ExecutionContext
used by this server.public Completable closeAsync()
AsyncCloseable
closeAsync
in interface AsyncCloseable
CompletableSource
that is notified once the close is complete.public Completable closeAsyncGracefully()
AsyncCloseable
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()
.
closeAsyncGracefully
in interface AsyncCloseable
Completable
that is notified once the close is complete.public Completable onClose()
ListenableAsyncCloseable
Completable
that is notified once the ListenableAsyncCloseable
was closed.onClose
in interface ListenableAsyncCloseable
Completable
that is notified on close.