pub struct WorkflowEventBus { /* private fields */ }Expand description
Per-workflow broadcast event bus for real-time monitoring.
Maintains one tokio::sync::broadcast channel per workflow run.
Consumers call subscribe to receive events for a
specific run; producers call publish to broadcast
an event to all subscribers of that run.
Thread-safe and cheaply cloneable (Clone shares the same inner state).
§Examples
use ironflow_engine::notify::{WorkflowEventBus, WorkflowEvent};
use uuid::Uuid;
use chrono::Utc;
let bus = WorkflowEventBus::new();
let run_id = Uuid::now_v7();
let mut rx = bus.subscribe(run_id);
bus.publish(run_id, WorkflowEvent::StepStarted {
step_name: "build".to_string(),
step_index: 0,
timestamp: Utc::now(),
});Implementations§
Source§impl WorkflowEventBus
impl WorkflowEventBus
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new empty event bus.
§Examples
use ironflow_engine::notify::WorkflowEventBus;
let bus = WorkflowEventBus::new();Sourcepub fn subscribe(&self, run_id: Uuid) -> Receiver<WorkflowEvent>
pub fn subscribe(&self, run_id: Uuid) -> Receiver<WorkflowEvent>
Subscribe to events for a specific workflow run.
If no channel exists for this run_id, one is created on demand.
Returns a broadcast receiver that yields WorkflowEvents for
that run only.
§Examples
use ironflow_engine::notify::WorkflowEventBus;
use uuid::Uuid;
let bus = WorkflowEventBus::new();
let run_id = Uuid::now_v7();
let _rx = bus.subscribe(run_id);Sourcepub fn publish(&self, run_id: Uuid, event: WorkflowEvent)
pub fn publish(&self, run_id: Uuid, event: WorkflowEvent)
Broadcast an event to all subscribers of a specific workflow run.
If no channel exists for run_id (no subscriber has called
subscribe), the event is silently dropped.
If subscribers exist but none are actively listening, the send
error is ignored.
§Examples
use ironflow_engine::notify::{WorkflowEventBus, WorkflowEvent};
use uuid::Uuid;
use chrono::Utc;
let bus = WorkflowEventBus::new();
let run_id = Uuid::now_v7();
// No subscriber -- silently dropped.
bus.publish(run_id, WorkflowEvent::StepStarted {
step_name: "build".to_string(),
step_index: 0,
timestamp: Utc::now(),
});Sourcepub fn remove(&self, run_id: Uuid)
pub fn remove(&self, run_id: Uuid)
Remove the channel for a workflow run.
Call this when a run completes or is cleaned up to free resources.
If no channel exists for run_id, this is a no-op.
§Examples
use ironflow_engine::notify::WorkflowEventBus;
use uuid::Uuid;
let bus = WorkflowEventBus::new();
let run_id = Uuid::now_v7();
let _rx = bus.subscribe(run_id);
bus.remove(run_id);Trait Implementations§
Source§impl Clone for WorkflowEventBus
impl Clone for WorkflowEventBus
Source§fn clone(&self) -> WorkflowEventBus
fn clone(&self) -> WorkflowEventBus
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more