public class ChannelOperations<INBOUND extends NettyInbound,OUTBOUND extends NettyOutbound> extends Object implements NettyInbound, NettyOutbound, NettyContext, Subscriber<Void>
Channel
and NettyInbound
/
NettyOutbound
semantics exposed to user
Connector.newHandler(BiFunction)
Modifier and Type | Class and Description |
---|---|
static interface |
ChannelOperations.OnNew<CHANNEL extends Channel>
A
ChannelOperations factory |
Modifier and Type | Field and Description |
---|---|
protected static AttributeKey<ChannelOperations> |
OPERATIONS_KEY
The attribute in
Channel to store the current ChannelOperations |
Modifier | Constructor and Description |
---|---|
protected |
ChannelOperations(Channel channel,
java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> handler,
ContextHandler<?> context) |
protected |
ChannelOperations(Channel channel,
java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> handler,
ContextHandler<?> context,
DirectProcessor<Void> processor) |
protected |
ChannelOperations(Channel channel,
ChannelOperations<INBOUND,OUTBOUND> replaced) |
Modifier and Type | Method and Description |
---|---|
InetSocketAddress |
address()
Return remote address if remote channel
NettyContext otherwise local
address if server selector channel. |
protected void |
applyHandler()
Apply the user-provided
NettyConnector handler |
static <INBOUND extends NettyInbound,OUTBOUND extends NettyOutbound> |
bind(Channel channel,
java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> handler,
ContextHandler<?> context)
|
Channel |
channel()
Return the underlying
Channel . |
NettyContext |
context()
Return a
NettyContext to operate on the underlying
Channel state. |
ChannelOperations<INBOUND,OUTBOUND> |
context(java.util.function.Consumer<NettyContext> contextCallback)
Immediately call the passed callback with a
NettyContext to operate on the
underlying
Channel state. |
protected boolean |
discreteRemoteClose(Throwable err)
Try filtering out remote close unless traced, return true if filtered
|
void |
dispose() |
protected String |
formatName()
Return formatted name of this operation
|
static ChannelOperations<?,?> |
get(Channel ch)
Return the current
Channel bound
ChannelOperations or null if none |
protected java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> |
handler()
Connector handler provided by user
|
boolean |
isDisposed() |
protected boolean |
isInboundCancelled()
Return true if inbound traffic is not expected anymore
|
protected boolean |
isInboundDone()
Return true if inbound traffic is not expected anymore
|
protected boolean |
isOutboundDone()
Return true if inbound traffic is not expected anymore
|
static <INBOUND extends NettyInbound,OUTBOUND extends NettyOutbound> |
noopHandler()
Return a Noop
BiFunction handler |
Mono<Void> |
onClose()
Return an observing
Mono terminating with success when shutdown
successfully
or error. |
NettyContext |
onClose(Runnable onClose)
Assign a
Runnable to be invoked when the channel is closed. |
void |
onComplete() |
void |
onError(Throwable t) |
protected void |
onHandlerStart()
React on input initialization
|
protected void |
onHandlerTerminate()
Final release/close (last packet)
|
protected void |
onInboundCancel()
React on inbound cancel (receive() subscriber cancelled)
|
protected void |
onInboundComplete()
React on inbound completion (last packet)
|
protected void |
onInboundError(Throwable err)
React on inbound error
|
protected void |
onInboundNext(ChannelHandlerContext ctx,
Object msg)
React on inbound
Channel.read() |
void |
onNext(Void aVoid) |
protected void |
onOutboundComplete()
React on inbound/outbound completion (last packet)
|
protected void |
onOutboundError(Throwable err)
React on inbound/outbound error
|
void |
onSubscribe(Subscription s) |
protected ContextHandler<?> |
parentContext()
Return the available parent
ContextHandler for user-facing lifecycle
handling |
Flux<?> |
receiveObject()
a Object inbound
Flux |
InetSocketAddress |
remoteAddress()
Get the address of the remote peer.
|
protected boolean |
replace(ChannelOperations<?,?> ops)
Replace and complete previous operation inbound
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
attr, onReadIdle, receive
alloc, onWriteIdle, options, send, sendByteArray, sendFile, sendFile, sendGroups, sendObject, sendObject, sendString, sendString, subscribe, then
neverComplete, then
addHandler, addHandler, addHandlerFirst, addHandlerFirst, addHandlerLast, addHandlerLast, isPersistent, markPersistent, removeHandler, replaceHandler
protected static final AttributeKey<ChannelOperations> OPERATIONS_KEY
Channel
to store the current ChannelOperations
protected ChannelOperations(Channel channel, ChannelOperations<INBOUND,OUTBOUND> replaced)
protected ChannelOperations(Channel channel, java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> handler, ContextHandler<?> context)
protected ChannelOperations(Channel channel, java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> handler, ContextHandler<?> context, DirectProcessor<Void> processor)
public static <INBOUND extends NettyInbound,OUTBOUND extends NettyOutbound> ChannelOperations<INBOUND,OUTBOUND> bind(Channel channel, java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> handler, ContextHandler<?> context)
ChannelOperations
attached to the Channel
attribute
OPERATIONS_KEY
.
Attach the NettyPipeline.ReactiveBridge
handle.INBOUND
- the NettyInbound
typeOUTBOUND
- the NettyOutbound
typechannel
- the new Channel
connectionhandler
- the user-provided BiFunction
i/o handlercontext
- the dispose callbackChannelOperations
bridgepublic static <INBOUND extends NettyInbound,OUTBOUND extends NettyOutbound> java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> noopHandler()
BiFunction
handlerINBOUND
- reified inbound typeOUTBOUND
- reified outbound typeBiFunction
handlerpublic static ChannelOperations<?,?> get(Channel ch)
Channel
bound
ChannelOperations
or null if nonech
- the current Channel
Channel
bound
ChannelOperations
or null if nonepublic InetSocketAddress address()
NettyContext
NettyContext
otherwise local
address if server selector channel.address
in interface NettyContext
InetSocketAddress
public final Channel channel()
NettyContext
Channel
. Direct interaction might be considered
insecure if that affects the
underlying IO processing such as read, write or close or state such as pipeline
handler addition/removal.channel
in interface NettyContext
Channel
public final NettyContext context()
NettyInbound
NettyContext
to operate on the underlying
Channel
state.context
in interface NettyInbound
context
in interface NettyOutbound
NettyContext
public ChannelOperations<INBOUND,OUTBOUND> context(java.util.function.Consumer<NettyContext> contextCallback)
NettyInbound
NettyContext
to operate on the
underlying
Channel
state. This allows for chaining inbound API.context
in interface NettyInbound
context
in interface NettyOutbound
contextCallback
- context callbackNettyContext
public void dispose()
dispose
in interface Cancellation
dispose
in interface Disposable
dispose
in interface NettyContext
public final boolean isDisposed()
isDisposed
in interface Disposable
isDisposed
in interface NettyContext
public final Mono<Void> onClose()
NettyContext
Mono
terminating with success when shutdown
successfully
or error.onClose
in interface NettyContext
Mono
terminating with success if shutdown successfully or errorpublic NettyContext onClose(Runnable onClose)
NettyContext
Runnable
to be invoked when the channel is closed.onClose
in interface NettyContext
onClose
- the close event handlerpublic final void onComplete()
onComplete
in interface Subscriber<Void>
public final void onError(Throwable t)
onError
in interface Subscriber<Void>
public final void onNext(Void aVoid)
onNext
in interface Subscriber<Void>
public final void onSubscribe(Subscription s)
onSubscribe
in interface Subscriber<Void>
public Flux<?> receiveObject()
NettyInbound
Flux
receiveObject
in interface NettyInbound
Flux
public final InetSocketAddress remoteAddress()
NettyInbound
remoteAddress
in interface NettyInbound
protected final boolean isInboundDone()
protected final boolean isInboundCancelled()
protected final boolean isOutboundDone()
protected final java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> handler()
protected void onHandlerStart()
protected void onInboundNext(ChannelHandlerContext ctx, Object msg)
Channel.read()
ctx
- the contextmsg
- the read payloadprotected final boolean replace(ChannelOperations<?,?> ops)
ops
- a new operationsprotected void onInboundCancel()
protected void onInboundComplete()
protected void onOutboundComplete()
protected void onOutboundError(Throwable err)
err
- the Throwable
causeprotected final void applyHandler()
NettyConnector
handlerprotected final boolean discreteRemoteClose(Throwable err)
err
- the error to checkprotected final void onHandlerTerminate()
protected final void onInboundError(Throwable err)
err
- the Throwable
causeprotected final ContextHandler<?> parentContext()
ContextHandler
for user-facing lifecycle
handlingContextHandler
for user-facing lifecycle
handlingprotected final String formatName()