Interface StreamingResponseContext
Runtime context for a streaming response producer.
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionThe underlying cancelation cause, if available.default @NonNull Optional<StreamTerminationReason> The cancelation reason, if canceled.The cancelation token for this streaming response.The absolute deadline for this stream, if one is configured.The idle timeout for this stream, if one is configured.The request that produced this streaming response.Is the streaming response canceled?default @NonNull AutoCloseableRegisters a callback that runs when the stream is canceled.default voidThrows if the stream has been canceled.
-
Method Details
-
getCancelationToken
The cancelation token for this streaming response.- Returns:
- the cancelation token
-
getRequest
The request that produced this streaming response.- Returns:
- the request that produced this streaming response
-
getDeadline
The absolute deadline for this stream, if one is configured.- Returns:
- the streaming deadline, or
Optional.empty()if no deadline is configured
-
getIdleTimeout
The idle timeout for this stream, if one is configured.- Returns:
- the streaming idle timeout, or
Optional.empty()if disabled
-
isCanceled
-
getCancelationReason
The cancelation reason, if canceled.- Returns:
- the cancelation reason, or
Optional.empty()if not canceled
-
getCancelationCause
The underlying cancelation cause, if available.- Returns:
- the underlying cause, or
Optional.empty()if none is available
-
onCancel
Registers a callback that runs when the stream is canceled.- Parameters:
callback- the callback to run on cancelation- Returns:
- a handle that removes the callback when closed
-
throwIfCanceled
Throws if the stream has been canceled.- Throws:
StreamingResponseCanceledException- if canceled
-