T
- ServerTransport implementationCONF
- Server Configuration implementationpublic abstract class ServerTransport<T extends ServerTransport<T,CONF>,CONF extends ServerTransportConfig<CONF>> extends Transport<T,CONF>
Constructor and Description |
---|
ServerTransport() |
Modifier and Type | Method and Description |
---|---|
Mono<? extends DisposableServer> |
bind()
|
DisposableServer |
bindNow()
Starts the server in a blocking fashion, and waits for it to finish initializing
or the startup timeout expires (the startup timeout is
45 seconds). |
DisposableServer |
bindNow(Duration timeout)
Start the server in a blocking fashion, and wait for it to finish initializing
or the provided startup timeout expires.
|
void |
bindUntilJavaShutdown(Duration timeout,
Consumer<DisposableServer> onStart)
Start the server in a fully blocking fashion, not only waiting for it to initialize
but also blocking during the full lifecycle of the server.
|
<A> T |
childAttr(AttributeKey<A> key,
A value)
Injects default attribute to the future child
Channel connections. |
T |
childObserve(ConnectionObserver observer)
Set or add the given
ConnectionObserver for each remote connection. |
<A> T |
childOption(ChannelOption<A> key,
A value)
Injects default options to the future child
Channel connections. |
T |
doOnBind(Consumer<? super CONF> doOnBind)
Set or add a callback called when
ServerTransport is about to start listening for incoming traffic. |
T |
doOnBound(Consumer<? super DisposableServer> doOnBound)
Set or add a callback called after
DisposableServer has been started. |
T |
doOnConnection(Consumer<? super Connection> doOnConnection)
Set or add a callback called on new remote
Connection . |
T |
doOnUnbound(Consumer<? super DisposableServer> doOnUnbound)
Set or add a callback called after
DisposableServer has been shutdown. |
T |
host(String host)
The host to which this server should bind.
|
T |
port(int port)
The port to which this server should bind.
|
Mono<Void> |
warmup()
Based on the actual configuration, returns a
Mono that triggers:
an initialization of the event loop groups
loads the necessary native libraries for the transport
By default, when method is not used, the bind operation absorbs the extra time needed to load resources. |
attr, bindAddress, channelGroup, configuration, doOnChannelInit, duplicate, metrics, metrics, observe, option, runOn, runOn, runOn, wiretap, wiretap, wiretap, wiretap, wiretap
public Mono<? extends DisposableServer> bind()
ServerTransport
and returns a Mono
of DisposableServer
. If
Mono
is cancelled, the underlying binding will be aborted. Once the DisposableServer
has been emitted and is not necessary anymore, disposing the main server
loop must be done by the user via DisposableChannel.dispose()
.Mono
of DisposableServer
public final DisposableServer bindNow()
45
seconds). The
returned DisposableServer
offers simple server API, including to DisposableChannel.disposeNow()
shut it down in a blocking fashion.Mono
of Connection
public final DisposableServer bindNow(Duration timeout)
DisposableServer
offers simple server API, including to DisposableChannel.disposeNow()
shut it down in a blocking fashion.timeout
- max startup timeout (resolution: ns)DisposableServer
public final void bindUntilJavaShutdown(Duration timeout, @Nullable Consumer<DisposableServer> onStart)
sigkill
.
Note: JVM shutdown hook
is added by
this method in order to properly disconnect the server upon receiving a
sigkill
signal.
timeout
- a timeout for server shutdownonStart
- an optional callback on server startpublic <A> T childAttr(AttributeKey<A> key, @Nullable A value)
Channel
connections. It
will be available via AttributeMap.attr(AttributeKey)
.
If the value
is null
, the attribute of the specified key
is removed.A
- the attribute typekey
- the attribute keyvalue
- the attribute value - null to remove a keyServerTransport
referenceServerBootstrap.childAttr(AttributeKey, Object)
public T childObserve(ConnectionObserver observer)
ConnectionObserver
for each remote connection.observer
- the ConnectionObserver
additionServerTransport
referencepublic <A> T childOption(ChannelOption<A> key, @Nullable A value)
Channel
connections. It
will be available via Channel.config()
.
If the value
is null
, the attribute of the specified key
is removed.
Note: Setting ChannelOption.AUTO_READ
option will be ignored. It is configured to be false
.A
- the option typekey
- the option keyvalue
- the option value - null to remove a keyServerTransport
referenceServerBootstrap.childOption(ChannelOption, Object)
public T doOnBind(Consumer<? super CONF> doOnBind)
ServerTransport
is about to start listening for incoming traffic.doOnBind
- a consumer observing connected eventsServerTransport
referencepublic T doOnBound(Consumer<? super DisposableServer> doOnBound)
DisposableServer
has been started.doOnBound
- a consumer observing connected eventsServerTransport
referencepublic T doOnConnection(Consumer<? super Connection> doOnConnection)
Connection
.doOnConnection
- a consumer observing remote connectionsServerTransport
referencepublic T doOnUnbound(Consumer<? super DisposableServer> doOnUnbound)
DisposableServer
has been shutdown.doOnUnbound
- a consumer observing unbound eventsServerTransport
referencepublic T host(String host)
host
- the host to bind to.ServerTransport
referencepublic T port(int port)
port
- The port to bind to.ServerTransport
referencepublic Mono<Void> warmup()
Mono
that triggers:
bind operation
absorbs the extra time needed to load resources.Mono
representing the completion of the warmup