Package ai.djl.inference.streaming
Class PublisherBytesSupplier
java.lang.Object
ai.djl.inference.streaming.PublisherBytesSupplier
- All Implemented Interfaces:
BytesSupplier
An
PublisherBytesSupplier is a streaming BytesSupplier suitable for reactive
asynchronous usage.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendContent(byte[] data, boolean lastChunk) Appends content to theBytesSupplier.Adds the subscriber to theBytesSupplierto get notified about additional data.Returns theByteBufferpresentation of the object.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ai.djl.ndarray.BytesSupplier
getAsBytes, getAsObject, getAsString
-
Constructor Details
-
PublisherBytesSupplier
public PublisherBytesSupplier()Constructs aPublisherBytesSupplier.
-
-
Method Details
-
appendContent
public void appendContent(byte[] data, boolean lastChunk) Appends content to theBytesSupplier.- Parameters:
data- bytes to appendlastChunk- true if this is the last chunk
-
subscribe
Adds the subscriber to theBytesSupplierto 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
CompletableFutureobject
-
toByteBuffer
Returns theByteBufferpresentation of the object.- Specified by:
toByteBufferin interfaceBytesSupplier- Returns:
- the
ByteBufferpresentation of the object
-