Package vn.payos.core
Interface AsyncStreamResponse<T>
- All Known Implementing Classes:
AsyncAutoPager
public interface AsyncStreamResponse<T>
AsyncStreamResponse
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceHandler interface for processing streaming responses.static enumStream state enumeration -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this resource, relinquishing any underlying resources.Returns a future that completes when a stream is fully consumed, errors, or gets closed early.subscribe(AsyncStreamResponse.Handler<T> handler) Registers handler to be called for events of this stream.subscribe(AsyncStreamResponse.Handler<T> handler, Executor executor) Registers handler to be called for events of this stream.
-
Method Details
-
subscribe
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.
- Parameters:
handler- Handler to process items and completion events- Returns:
- this AsyncStreamResponse for chaining
- Throws:
IllegalStateException- if subscribe has already been called
-
subscribe
Registers handler to be called for events of this stream.Handler's methods will be called in the given executor.
- Parameters:
handler- Handler to process items and completion eventsexecutor- Executor to run handler methods in- Returns:
- this AsyncStreamResponse for chaining
- Throws:
IllegalStateException- if subscribe has already been called
-
onCompleteFuture
CompletableFuture<Void> onCompleteFuture()Returns a future that completes when a stream is fully consumed, errors, or gets closed early.- Returns:
- CompletableFuture for completion tracking
-
close
void 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.
-