Package io.micronaut.http.netty.reactive
Class HandlerSubscriber<T>
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.channel.ChannelDuplexHandler
-
- io.micronaut.http.netty.reactive.HandlerSubscriber<T>
-
- Type Parameters:
T- The subscriber type
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,io.netty.channel.ChannelOutboundHandler,org.reactivestreams.Subscriber<T>
@Internal public class HandlerSubscriber<T> extends io.netty.channel.ChannelDuplexHandler implements org.reactivestreams.Subscriber<T>Subscriber that publishes received messages to the handler pipeline.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description protected io.netty.channel.ChannelFuturelastWriteFuture
-
Constructor Summary
Constructors Constructor Description HandlerSubscriber(io.netty.util.concurrent.EventExecutor executor)Create a new handler subscriber with the default low and high watermarks.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchannelActive(io.netty.channel.ChannelHandlerContext ctx)voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx)voidchannelRegistered(io.netty.channel.ChannelHandlerContext ctx)voidchannelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx)protected voidcomplete()Override for custom completion handling.protected voiderror(java.lang.Throwable error)Override for custom error handling.voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause)voidhandlerAdded(io.netty.channel.ChannelHandlerContext ctx)voidhandlerRemoved(io.netty.channel.ChannelHandlerContext ctx)voidonComplete()voidonError(java.lang.Throwable error)voidonNext(T t)protected voidonNext(T t, io.netty.channel.ChannelPromise promise)Write the message with the supplied promise.voidonSubscribe(org.reactivestreams.Subscription subscription)-
Methods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, read, write
-
-
-
-
Constructor Detail
-
HandlerSubscriber
public HandlerSubscriber(io.netty.util.concurrent.EventExecutor executor)
Create a new handler subscriber with the default low and high watermarks.The supplied executor must be the same event loop as the event loop that this handler is eventually registered with, if not, an exception will be thrown when the handler is registered.
- Parameters:
executor- The executor to execute asynchronous events from the publisher on.
-
-
Method Detail
-
error
protected void error(java.lang.Throwable error)
Override for custom error handling. By default, it closes the channel.- Parameters:
error- The error to handle.
-
complete
protected void complete()
Override for custom completion handling. By default, it closes the channel.
-
handlerAdded
public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
- Specified by:
handlerAddedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerAddedin classio.netty.channel.ChannelHandlerAdapter
-
channelRegistered
public void channelRegistered(io.netty.channel.ChannelHandlerContext ctx)
- Specified by:
channelRegisteredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelRegisteredin classio.netty.channel.ChannelInboundHandlerAdapter
-
channelWritabilityChanged
public void channelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx)
- Specified by:
channelWritabilityChangedin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelWritabilityChangedin classio.netty.channel.ChannelInboundHandlerAdapter
-
channelActive
public void channelActive(io.netty.channel.ChannelHandlerContext ctx)
- Specified by:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classio.netty.channel.ChannelInboundHandlerAdapter
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter
-
handlerRemoved
public void handlerRemoved(io.netty.channel.ChannelHandlerContext ctx)
- Specified by:
handlerRemovedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerRemovedin classio.netty.channel.ChannelHandlerAdapter
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause)- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter
-
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription subscription)
- Specified by:
onSubscribein interfaceorg.reactivestreams.Subscriber<T>
-
onNext
protected void onNext(T t, io.netty.channel.ChannelPromise promise)
Write the message with the supplied promise.- Parameters:
t- The messagepromise- The promise
-
onError
public void onError(java.lang.Throwable error)
- Specified by:
onErrorin interfaceorg.reactivestreams.Subscriber<T>
-
onComplete
public void onComplete()
- Specified by:
onCompletein interfaceorg.reactivestreams.Subscriber<T>
-
-