pub struct EventsClient { /* private fields */ }Expand description
Sub-client for SSE event streams. Obtained via [AkribesClient::events()].
Implementations§
Source§impl EventsClient
impl EventsClient
Sourcepub async fn event_stream(
&self,
script_name: Option<&str>,
) -> Result<(UnboundedReceiver<HubEvent>, EventSubscription)>
pub async fn event_stream( &self, script_name: Option<&str>, ) -> Result<(UnboundedReceiver<HubEvent>, EventSubscription)>
Open an SSE event stream and return a receiver + subscription handle.
Events are sent to the returned mpsc::UnboundedReceiver. Dropping the
EventSubscription cancels the background task automatically.
Note: The channel is unbounded — a slow consumer on a busy execution
stream can cause unbounded memory growth. Callers should process events
promptly, use tokio::sync::mpsc::Receiver::try_recv to drain, or
prefer event_stream_bounded (#1117)
when consumer back-pressure is required.
Sourcepub async fn event_stream_bounded(
&self,
script_name: Option<&str>,
buffer: usize,
) -> Result<(Receiver<HubEvent>, EventSubscription)>
pub async fn event_stream_bounded( &self, script_name: Option<&str>, buffer: usize, ) -> Result<(Receiver<HubEvent>, EventSubscription)>
Open an SSE event stream on a bounded channel (#1117).
buffer is the channel’s max in-flight event count. When the
consumer can’t keep up, the background SSE listener applies
back-pressure: it parks until the consumer drains a slot.
This is the safer default for long-lived subscriptions on busy
executions — the unbounded variant can grow unboundedly when
the consumer stalls. The trade-off is that prolonged stalls can
stall the SSE listener too, which counts against the
server-side keepalive window; pick buffer generously
(e.g. 1024) when in doubt.
Returns a standard bounded mpsc::Receiver; otherwise identical
to event_stream.
Sourcepub async fn execution_stream(
&self,
script_name: &str,
) -> Result<(UnboundedReceiver<EngineEvent>, EventSubscription)>
pub async fn execution_stream( &self, script_name: &str, ) -> Result<(UnboundedReceiver<EngineEvent>, EventSubscription)>
Stream execution engine events for a specific script.
Sourcepub async fn typed_execution_stream(
&self,
script_name: &str,
) -> Result<(UnboundedReceiver<WorkflowEvent>, EventSubscription)>
pub async fn typed_execution_stream( &self, script_name: &str, ) -> Result<(UnboundedReceiver<WorkflowEvent>, EventSubscription)>
Stream execution events translated to typed [WorkflowEvent]s for a
specific script (#1239 — mirrors Python events.typed_engine_events).
Functionally identical to execution_stream,
but each event is passed through WorkflowEvent::from(EngineEvent)
before being yielded so consumers can pattern-match on typed
variants instead of inspecting raw EngineEvent payloads. Use
this when you want the same ergonomics as RunStream’s typed
iterator on a free-standing execution subscription (e.g. attaching
to a run started by someone else).
Sourcepub async fn on_events<F>(
&self,
script_name: Option<&str>,
callback: F,
) -> Result<EventSubscription>
pub async fn on_events<F>( &self, script_name: Option<&str>, callback: F, ) -> Result<EventSubscription>
Convenience: call callback for every hub event.
Sourcepub async fn on_script_execution<F>(
&self,
script_name: &str,
callback: F,
) -> Result<EventSubscription>
pub async fn on_script_execution<F>( &self, script_name: &str, callback: F, ) -> Result<EventSubscription>
Convenience: call callback for every execution event on a script.
Sourcepub async fn on_script_change<F>(
&self,
script_name: &str,
callback: F,
) -> Result<EventSubscription>
pub async fn on_script_change<F>( &self, script_name: &str, callback: F, ) -> Result<EventSubscription>
Convenience: call callback on script version updates.
Sourcepub async fn on_script_schema_change<F>(
&self,
script_name: &str,
callback: F,
) -> Result<EventSubscription>
pub async fn on_script_schema_change<F>( &self, script_name: &str, callback: F, ) -> Result<EventSubscription>
Like on_script_change, but also marks the
script as broken in the contract state so that subsequent run() calls
raise before POSTing (matching the TS and Python SDK behaviour).
Trait Implementations§
Source§impl Clone for EventsClient
impl Clone for EventsClient
Source§fn clone(&self) -> EventsClient
fn clone(&self) -> EventsClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more