Class NettyBodyAdapter

java.lang.Object
io.micronaut.http.server.netty.body.NettyBodyAdapter
All Implemented Interfaces:
BufferConsumer.Upstream, Subscriber<io.netty.buffer.ByteBuf>

@Internal public final class NettyBodyAdapter extends Object implements BufferConsumer.Upstream, Subscriber<io.netty.buffer.ByteBuf>
Adapter from generic streaming ByteBody to StreamingNettyByteBody.
Since:
4.6.0
Author:
Jonas Konrad
  • Method Details

    • adapt

      @NonNull public static @NonNull NettyByteBody adapt(@NonNull @NonNull ByteBody body, @NonNull @NonNull io.netty.channel.EventLoop eventLoop)
      Transform the given body to a NettyByteBody.
      Parameters:
      body - The generic body
      eventLoop - The event loop for task serialization
      Returns:
      The adapted body
    • adapt

      public static StreamingNettyByteBody adapt(Publisher<io.netty.buffer.ByteBuf> publisher, io.netty.channel.EventLoop eventLoop)
    • start

      public void start()
      Description copied from interface: BufferConsumer.Upstream
      Signal that we want to start consuming bytes. This is an optional hint to the upstream, the upstream may ignore it and send bytes immediately. This is used for CONTINUE support.
      Specified by:
      start in interface BufferConsumer.Upstream
    • onBytesConsumed

      public void onBytesConsumed(long bytesConsumed)
      Description copied from interface: BufferConsumer.Upstream
      Called when a number of bytes has been consumed by the downstream.
      Specified by:
      onBytesConsumed in interface BufferConsumer.Upstream
      Parameters:
      bytesConsumed - The number of bytes that were consumed
    • allowDiscard

      public void allowDiscard()
      Description copied from interface: BufferConsumer.Upstream
      Allow the upstream to discard any further messages. Note that this does not actually mean the messages must be discarded: If another consumer still needs the body data, it may continue to be read and continue to be forwarded to this consumer.
      Specified by:
      allowDiscard in interface BufferConsumer.Upstream
    • disregardBackpressure

      public void disregardBackpressure()
      Description copied from interface: BufferConsumer.Upstream
      Instruct the upstream to ignore backpressure from this consumer. This is slightly different from onBytesConsumed(Long.MAX_VALUE): If there are two consumers in ByteBody.SplitBackpressureMode.FASTEST mode, a MAX_VALUE requests all data from the common upstream, while a disregardBackpressure removes this downstream from consideration.
      Specified by:
      disregardBackpressure in interface BufferConsumer.Upstream
    • onSubscribe

      public void onSubscribe(Subscription s)
      Specified by:
      onSubscribe in interface Subscriber<io.netty.buffer.ByteBuf>
    • onNext

      public void onNext(io.netty.buffer.ByteBuf bytes)
      Specified by:
      onNext in interface Subscriber<io.netty.buffer.ByteBuf>
    • onError

      public void onError(Throwable t)
      Specified by:
      onError in interface Subscriber<io.netty.buffer.ByteBuf>
    • onComplete

      public void onComplete()
      Specified by:
      onComplete in interface Subscriber<io.netty.buffer.ByteBuf>