Interface BufferConsumer

All Known Implementing Classes:
BaseSharedBuffer, BaseSharedBuffer.AsFlux, ConcatenatingSubscriber, FormDemuxer, ReactiveByteBufferByteBody.SharedBuffer, StreamingNettyByteBody.SharedBuffer

@Internal public interface BufferConsumer
This is a reactor-like API for streaming bytes. It's a bit better than reactor because it's more explicit about reference counting semantics, has more fine-grained controls for cancelling, and has more relaxed concurrency semantics.
Since:
4.8.0
Author:
Jonas Konrad
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    This interface manages the backpressure for data consumptions.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Send a buffer to this consumer.
    default void
    Send a final buffer to this consumer and signal normal completion of the stream, in one operation.
    void
    Signal normal completion of the stream.
    default void
    Signal that the upstream has discarded the remaining data, as requested by BufferConsumer.Upstream.allowDiscard().
    void
    Signal an upstream error.
  • Method Details

    • add

      void add(ReadBuffer rb)
      Send a buffer to this consumer. Ownership of the buffer transfers to the consumer.
      Parameters:
      rb - The buffer
    • complete

      void complete()
      Signal normal completion of the stream.
    • addAndComplete

      default void addAndComplete(ReadBuffer rb)
      Send a final buffer to this consumer and signal normal completion of the stream, in one operation. Ownership of the buffer transfers to the consumer.

      This is semantically identical to add(ReadBuffer) followed by complete(). Implementations may override it to combine the two into a single downstream message, e.g. to write the trailing bytes of a response as part of the message that terminates it.

      Parameters:
      rb - The final buffer
    • discard

      default void discard()
      Signal that the upstream has discarded the remaining data, as requested by BufferConsumer.Upstream.allowDiscard().
    • error

      void error(Throwable e)
      Signal an upstream error.
      Parameters:
      e - The error