Package com.openai.core.http
Interface AsyncStreamResponse
-
- All Implemented Interfaces:
public interface AsyncStreamResponse<T extends Object>
A class providing access to an API response as an asynchronous stream of chunks of type T, where each chunk can be individually processed as soon as it arrives instead of waiting on the full response.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
AsyncStreamResponse.Handler
A class for handling streaming events.
-
Method Summary
Modifier and Type Method Description abstract AsyncStreamResponse<T>
subscribe(AsyncStreamResponse.Handler<T> handler)
Registers handler to be called for events of this stream. abstract AsyncStreamResponse<T>
subscribe(AsyncStreamResponse.Handler<T> handler, Executor executor)
Registers handler to be called for events of this stream. abstract CompletableFuture<Void>
onCompleteFuture()
Returns a future that completes when a stream is fully consumed, errors, or gets closed early. abstract Unit
close()
Closes this resource, relinquishing any underlying resources. -
-
Method Detail
-
subscribe
abstract AsyncStreamResponse<T> subscribe(AsyncStreamResponse.Handler<T> handler)
Registers handler to be called for events of this stream.
handler's methods will be called in the client's configured or default thread pool.
-
subscribe
abstract AsyncStreamResponse<T> subscribe(AsyncStreamResponse.Handler<T> handler, Executor executor)
Registers handler to be called for events of this stream.
-
onCompleteFuture
abstract CompletableFuture<Void> onCompleteFuture()
Returns a future that completes when a stream is fully consumed, errors, or gets closed early.
-
close
abstract Unit close()
Closes this resource, relinquishing any underlying resources.
This is purposefully not inherited from AutoCloseable because this response should not be synchronously closed via try-with-resources.
-
-
-
-