Interface AlpacaSseSubscription
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
BrokerSseSubscription
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()SelectsAlpacaSseCloseResult.Reason.USER_CLOSEDwhen this call wins the terminal transition, cancels transport work, and waits forcompletion()to settle before returning.Returns terminal lifecycle completion.Returns the most recently accepted connection, including after closure.Returns the latest completed SSE event ID, including a completed data-lessid:block.opened()Completes with the first accepted connection.okhttp3.Requestrequest()Returns the original logical request used to create this subscription.state()
-
Method Details
-
request
okhttp3.Request request()Returns the original logical request used to create this subscription.Reconnect-specific resume headers and query parameters are applied to internal request copies and are not reflected here.
-
state
AlpacaSseState state() -
lastEventId
Returns the latest completed SSE event ID, including a completed data-lessid:block. -
connection
Optional<AlpacaSseConnectionInfo> connection()Returns the most recently accepted connection, including after closure. -
opened
CompletableFuture<AlpacaSseConnectionInfo> opened()Completes with the first accepted connection.Once the response is accepted, this future completes successfully with that connection even if closure races with opening. The ordered
onOpencallback remains ahead of the terminal listener callback.Keep synchronous continuations short. The lifecycle dependency above is supported, but use an asynchronous continuation such as
thenApplyAsyncwith an application-owned executor for unrelated or potentially unbounded blocking work.If the subscription terminates before opening,
completion()is settled before this future is cancelled or completed exceptionally. A synchronous opening continuation may therefore safely inspect terminal completion.Each call returns an independently settled defensive copy. Cancelling or manually completing one copy does not affect this subscription or another saved copy.
-
completion
CompletableFuture<AlpacaSseCloseResult> completion()Returns terminal lifecycle completion.Normal and user closure complete successfully; terminal failures complete exceptionally. Lifecycle completion is resolved before the serialized terminal listener callback and does not wait for an active user callback. Settlement is handed off from the active callback path, so a synchronous completion continuation may wait for the ordered terminal listener even when the active callback initiated closure.
Each call returns an independently settled defensive copy. Cancelling or manually completing one copy does not affect this subscription or another saved copy. Synchronous continuations run on isolated SDK lifecycle workers and must remain short. The ordered-terminal wait above is supported, and a blocked continuation does not delay another saved lifecycle copy or queue another subscription's settlement. Use an asynchronous continuation such as
thenApplyAsyncwith an application-owned executor for unrelated or potentially unbounded blocking work. -
close
void close()SelectsAlpacaSseCloseResult.Reason.USER_CLOSEDwhen this call wins the terminal transition, cancels transport work, and waits forcompletion()to settle before returning.If another terminal transition wins concurrently, this method observes its normal or exceptional completion without rethrowing the terminal failure.
- Specified by:
closein interfaceAutoCloseable
-