INBOUND - incoming traffic API such as server request or client responseOUTBOUND - outgoing traffic API such as server response or client requestpublic interface NettyConnector<INBOUND extends NettyInbound,OUTBOUND extends NettyOutbound>
Mono will effectively
create a new stateful "client" or "server" socket depending on the implementation.
It might also be working on top of a socket pool or connection pool as well, but the
state should be safely handled by the pool itself.
Clients or Receivers will onSubscribe when their connection is established. They
will complete when the unique returned closing Publisher completes itself or if
the connection is remotely terminated. Calling the returned Disposable.dispose() from Mono.subscribe() will terminate the subscription
and underlying connection from the local peer.
Servers or Producers will onSubscribe when their socket is bound locally. They will
never complete as many Publisher close selectors will be expected. Disposing
the returned Mono will safely call shutdown.
| Modifier and Type | Method and Description |
|---|---|
reactor.core.publisher.Mono<? extends NettyContext> |
newHandler(java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<java.lang.Void>> ioHandler)
Prepare a
BiFunction IO handler that will react on a new connected state
each
time
the returned Mono is subscribed. |
default <T extends java.util.function.BiFunction<INBOUND,OUTBOUND,? extends Publisher<java.lang.Void>>> |
start(T handler)
Start a Client or Server in a blocking fashion, and wait for it to finish initializing.
|
default <T extends java.util.function.BiFunction<INBOUND,OUTBOUND,? extends Publisher<java.lang.Void>>> |
start(T handler,
java.time.Duration timeout)
Start a Client or Server in a blocking fashion, and wait for it to finish initializing.
|
default <T extends java.util.function.BiFunction<INBOUND,OUTBOUND,? extends Publisher<java.lang.Void>>> |
startAndAwait(T handler)
Start a Client or Server in a fully blocking fashion, not only waiting for it to
initialize but also blocking during the full lifecycle of the client/server.
|
default <T extends java.util.function.BiFunction<INBOUND,OUTBOUND,? extends Publisher<java.lang.Void>>> |
startAndAwait(T handler,
java.util.function.Consumer<BlockingNettyContext> onStart)
Start a Client or Server in a fully blocking fashion, not only waiting for it to
initialize but also blocking during the full lifecycle of the client/server.
|
reactor.core.publisher.Mono<? extends NettyContext> newHandler(java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<java.lang.Void>> ioHandler)
BiFunction IO handler that will react on a new connected state
each
time
the returned Mono is subscribed. This NettyConnector shouldn't assume
any state related to the individual created/cleaned resources.
The IO handler will return Publisher to signal when to terminate the
underlying resource channel.
ioHandler - the in/out callback returning a closing publisherMono completing with a Disposable token to dispose
the active handler (server, client connection...) or failing with the connection
error.default <T extends java.util.function.BiFunction<INBOUND,OUTBOUND,? extends Publisher<java.lang.Void>>> BlockingNettyContext start(T handler)
BlockingNettyContext class offers a simplified API around operating
the client/server in a blocking fashion, including to shut it down.T - handler - the handler to start the client or server with.BlockingNettyContextdefault <T extends java.util.function.BiFunction<INBOUND,OUTBOUND,? extends Publisher<java.lang.Void>>> BlockingNettyContext start(T handler, java.time.Duration timeout)
BlockingNettyContext class offers a simplified API around operating
the client/server in a blocking fashion, including to shut it down.T - handler - the handler to start the client or server with.timeout - wait for Client/Server to start for the specified timeout.BlockingNettyContextdefault <T extends java.util.function.BiFunction<INBOUND,OUTBOUND,? extends Publisher<java.lang.Void>>> void startAndAwait(T handler)
Note that a JVM shutdown hook is added
by this method in order to properly disconnect the client/server upon receiving
a sigkill signal.
handler - the handler to execute.default <T extends java.util.function.BiFunction<INBOUND,OUTBOUND,? extends Publisher<java.lang.Void>>> void startAndAwait(T handler, @Nullable java.util.function.Consumer<BlockingNettyContext> onStart)
Note that a JVM shutdown hook is added
by this method in order to properly disconnect the client/server upon receiving
a sigkill signal.
handler - the handler to execute.onStart - an optional callback to be invoked once the client/server has finished
initializing.