Class BrokerSseSubscription
- All Implemented Interfaces:
AutoCloseable,AlpacaSseSubscription
Closing the handle cancels the underlying shared SSE subscription.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Cancels the SSE stream.Returns terminal lifecycle completion.Returns the most recently accepted connection, including after closure.okhttp3.sse.EventSourceReturns a stable OkHttp-compatible facade for this logical subscription.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
-
eventSource
public okhttp3.sse.EventSource eventSource()Returns a stable OkHttp-compatible facade for this logical subscription.This compatibility facade delegates
EventSource.request()andEventSource.cancel()to the shared SSE subscription; it is not the transport's underlying OkHttp event source. Identity, implementation casts, and access to the live OkHttp response are not supported. New code should callclose(). -
request
public okhttp3.Request request()Description copied from interface:AlpacaSseSubscriptionReturns 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.
- Specified by:
requestin interfaceAlpacaSseSubscription
-
state
- Specified by:
statein interfaceAlpacaSseSubscription
-
lastEventId
Description copied from interface:AlpacaSseSubscriptionReturns the latest completed SSE event ID, including a completed data-lessid:block.- Specified by:
lastEventIdin interfaceAlpacaSseSubscription
-
connection
Description copied from interface:AlpacaSseSubscriptionReturns the most recently accepted connection, including after closure.- Specified by:
connectionin interfaceAlpacaSseSubscription
-
opened
Description copied from interface:AlpacaSseSubscriptionCompletes 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,
AlpacaSseSubscription.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.
- Specified by:
openedin interfaceAlpacaSseSubscription
-
completion
Description copied from interface:AlpacaSseSubscriptionReturns 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.- Specified by:
completionin interfaceAlpacaSseSubscription
-
close
public void close()Cancels the SSE stream.- Specified by:
closein interfaceAlpacaSseSubscription- Specified by:
closein interfaceAutoCloseable
-