Class ReactiveDataProducer

java.lang.Object
org.apache.hc.core5.reactive.ReactiveDataProducer
All Implemented Interfaces:
AsyncDataProducer, ResourceHolder, org.reactivestreams.Subscriber<ByteBuffer>

@Contract(threading=SAFE) final class ReactiveDataProducer extends Object implements AsyncDataProducer, org.reactivestreams.Subscriber<ByteBuffer>
An asynchronous data producer that supports Reactive Streams.
Since:
5.0
  • Field Details

  • Constructor Details

    • ReactiveDataProducer

      public ReactiveDataProducer(org.reactivestreams.Publisher<ByteBuffer> publisher)
  • Method Details

    • setChannel

      void setChannel(DataStreamChannel channel)
    • onSubscribe

      public void onSubscribe(org.reactivestreams.Subscription subscription)
      Specified by:
      onSubscribe in interface org.reactivestreams.Subscriber<ByteBuffer>
    • onNext

      public void onNext(ByteBuffer byteBuffer)
      Specified by:
      onNext in interface org.reactivestreams.Subscriber<ByteBuffer>
    • onError

      public void onError(Throwable throwable)
      Specified by:
      onError in interface org.reactivestreams.Subscriber<ByteBuffer>
    • onComplete

      public void onComplete()
      Specified by:
      onComplete in interface org.reactivestreams.Subscriber<ByteBuffer>
    • signalReadiness

      private void signalReadiness()
    • available

      public int available()
      Description copied from interface: AsyncDataProducer
      Returns the number of bytes immediately available for output. This method can be used as a hint to control output events of the underlying I/O session.
      Specified by:
      available in interface AsyncDataProducer
      Returns:
      the number of bytes immediately available for output
    • produce

      public void produce(DataStreamChannel channel) throws IOException
      Description copied from interface: AsyncDataProducer
      Triggered to signal the ability of the underlying data channel to accept more data. The data producer can choose to write data immediately inside the call or asynchronously at some later point.
      Specified by:
      produce in interface AsyncDataProducer
      Parameters:
      channel - the data channel capable to accepting more data.
      Throws:
      IOException
    • releaseResources

      public void releaseResources()
      Specified by:
      releaseResources in interface ResourceHolder