Class PublisherBytesSupplier

java.lang.Object
ai.djl.inference.streaming.PublisherBytesSupplier
All Implemented Interfaces:
BytesSupplier

public class PublisherBytesSupplier extends Object implements BytesSupplier
An PublisherBytesSupplier is a streaming BytesSupplier suitable for reactive asynchronous usage.
  • Constructor Details

  • Method Details

    • appendContent

      public void appendContent(byte[] data, boolean lastChunk)
      Appends content to the BytesSupplier.
      Parameters:
      data - bytes to append
      lastChunk - true if this is the last chunk
    • subscribe

      public CompletableFuture<Void> subscribe(Consumer<byte[]> subscriber)
      Adds the subscriber to the BytesSupplier to get notified about additional data.
      Parameters:
      subscriber - a consumer function that will receive bytes when new daata is added and null when completed
      Returns:
      a CompletableFuture object
    • toByteBuffer

      public ByteBuffer toByteBuffer()
      Returns the ByteBuffer presentation of the object.
      Specified by:
      toByteBuffer in interface BytesSupplier
      Returns:
      the ByteBuffer presentation of the object