pub enum Event {
Show 15 variants
RunCreated(RunCreatedEvent),
RunStatusChanged(RunStatusChangedEvent),
RunFailed(RunFailedEvent),
RunBudgetExceeded(RunBudgetExceededEvent),
RetryForced(RetryForcedEvent),
StepCompleted(StepCompletedEvent),
StepFailed(StepFailedEvent),
ApprovalRequested(ApprovalRequestedEvent),
ApprovalGranted(ApprovalGrantedEvent),
ApprovalRejected(ApprovalRejectedEvent),
ApprovalEscalated(ApprovalEscalatedEvent),
LogLine(LogLineEvent),
UserSignedIn(UserSignedInEvent),
UserSignedUp(UserSignedUpEvent),
UserSignedOut(UserSignedOutEvent),
}Expand description
A domain event emitted by the ironflow system.
Covers the full lifecycle: runs, steps, approvals, and authentication.
Subscribers receive these via EventPublisher
and pattern-match on the variants they care about.
Each variant wraps a dedicated payload struct. The serialized form stays
flat: the type discriminant sits next to the payload fields, so
{"type":"run_created","run_id":...} round-trips unchanged.
§Examples
use std::collections::HashMap;
use ironflow_engine::notify::{Event, RunStatusChangedEvent};
use ironflow_store::models::RunStatus;
use uuid::Uuid;
let event = Event::RunStatusChanged(RunStatusChangedEvent {
run_id: Uuid::now_v7(),
workflow_name: "deploy".to_string(),
from: RunStatus::Running,
to: RunStatus::Completed,
error: None,
cost_usd: rust_decimal::Decimal::ZERO,
duration_ms: 5000,
labels: HashMap::new(),
at: chrono::Utc::now(),
});
assert_eq!(event.event_type(), "run_status_changed");Variants§
RunCreated(RunCreatedEvent)
A new run was created (status: Pending).
RunStatusChanged(RunStatusChangedEvent)
A run changed status.
RunFailed(RunFailedEvent)
A run transitioned to Failed.
This is a convenience event emitted alongside RunStatusChanged
when the target status is Failed. Subscribe to this instead of
RUN_STATUS_CHANGED when you only care about failures.
RunBudgetExceeded(RunBudgetExceededEvent)
A run was stopped because it reached its cumulative cost cap.
Emitted when the engine refuses an agent step that would cross the run’s
max_cost_usd. The run transitions to
Cancelled and the step
is never launched, so the reported spend is what the run had already
consumed.
RetryForced(RetryForcedEvent)
A manual retry was forced despite a handler version mismatch.
Emitted when a caller passes force=true on a retry where the
handler version differs from the run’s recorded version. This is
an audit event: it means the new code will execute on the old
payload without the handler explicitly declaring compatibility.
StepCompleted(StepCompletedEvent)
A step completed successfully.
StepFailed(StepFailedEvent)
A step failed.
ApprovalRequested(ApprovalRequestedEvent)
A run is waiting for human approval.
ApprovalGranted(ApprovalGrantedEvent)
A run was approved by a human.
ApprovalRejected(ApprovalRejectedEvent)
A run was rejected by a human.
ApprovalEscalated(ApprovalEscalatedEvent)
An approval gate missed its SLA deadline and an escalation policy ran.
LogLine(LogLineEvent)
A log line emitted during step execution.
Pushed by the worker in real time so that SSE clients can stream step output as it happens, without waiting for step completion.
UserSignedIn(UserSignedInEvent)
A user signed in.
UserSignedUp(UserSignedUpEvent)
A new user signed up.
UserSignedOut(UserSignedOutEvent)
A user signed out.
Implementations§
Source§impl Event
impl Event
Sourcepub const RUN_CREATED: &'static str = "run_created"
pub const RUN_CREATED: &'static str = "run_created"
Event type constant for RunCreated.
Sourcepub const RUN_STATUS_CHANGED: &'static str = "run_status_changed"
pub const RUN_STATUS_CHANGED: &'static str = "run_status_changed"
Event type constant for RunStatusChanged.
Sourcepub const RUN_FAILED: &'static str = "run_failed"
pub const RUN_FAILED: &'static str = "run_failed"
Event type constant for RunFailed.
Sourcepub const RUN_BUDGET_EXCEEDED: &'static str = "run_budget_exceeded"
pub const RUN_BUDGET_EXCEEDED: &'static str = "run_budget_exceeded"
Event type constant for RunBudgetExceeded.
Sourcepub const RETRY_FORCED: &'static str = "retry_forced"
pub const RETRY_FORCED: &'static str = "retry_forced"
Event type constant for RetryForced.
Sourcepub const STEP_COMPLETED: &'static str = "step_completed"
pub const STEP_COMPLETED: &'static str = "step_completed"
Event type constant for StepCompleted.
Sourcepub const STEP_FAILED: &'static str = "step_failed"
pub const STEP_FAILED: &'static str = "step_failed"
Event type constant for StepFailed.
Sourcepub const APPROVAL_REQUESTED: &'static str = "approval_requested"
pub const APPROVAL_REQUESTED: &'static str = "approval_requested"
Event type constant for ApprovalRequested.
Sourcepub const APPROVAL_GRANTED: &'static str = "approval_granted"
pub const APPROVAL_GRANTED: &'static str = "approval_granted"
Event type constant for ApprovalGranted.
Sourcepub const APPROVAL_REJECTED: &'static str = "approval_rejected"
pub const APPROVAL_REJECTED: &'static str = "approval_rejected"
Event type constant for ApprovalRejected.
Sourcepub const APPROVAL_ESCALATED: &'static str = "approval_escalated"
pub const APPROVAL_ESCALATED: &'static str = "approval_escalated"
Event type constant for ApprovalEscalated.
Sourcepub const USER_SIGNED_IN: &'static str = "user_signed_in"
pub const USER_SIGNED_IN: &'static str = "user_signed_in"
Event type constant for UserSignedIn.
Sourcepub const USER_SIGNED_UP: &'static str = "user_signed_up"
pub const USER_SIGNED_UP: &'static str = "user_signed_up"
Event type constant for UserSignedUp.
Sourcepub const USER_SIGNED_OUT: &'static str = "user_signed_out"
pub const USER_SIGNED_OUT: &'static str = "user_signed_out"
Event type constant for UserSignedOut.
Sourcepub const ALL: &'static [&'static str]
pub const ALL: &'static [&'static str]
All event types. Pass this to
EventPublisher::subscribe to
receive every event.
§Examples
use ironflow_engine::notify::{Event, EventPublisher, WebhookSubscriber};
let mut publisher = EventPublisher::new();
publisher.subscribe(
WebhookSubscriber::new("https://example.com/all"),
Event::ALL,
);Sourcepub fn event_type(&self) -> &'static str
pub fn event_type(&self) -> &'static str
Returns the event type as a static string (e.g. "run_status_changed").
Useful for filtering and logging without deserializing.
§Examples
use ironflow_engine::notify::{Event, UserSignedInEvent};
use uuid::Uuid;
use chrono::Utc;
let event = Event::UserSignedIn(UserSignedInEvent {
user_id: Uuid::now_v7(),
username: "alice".to_string(),
at: Utc::now(),
});
assert_eq!(event.event_type(), "user_signed_in");Sourcepub fn run_id(&self) -> Option<Uuid>
pub fn run_id(&self) -> Option<Uuid>
Returns the run this event belongs to, if any.
Auth events (UserSignedIn,
UserSignedUp,
UserSignedOut) are not tied to a run and
return None.
§Examples
use ironflow_engine::notify::{Event, RunCreatedEvent};
use uuid::Uuid;
use chrono::Utc;
let run_id = Uuid::now_v7();
let event = Event::RunCreated(RunCreatedEvent {
run_id,
workflow_name: "deploy".to_string(),
at: Utc::now(),
});
assert_eq!(event.run_id(), Some(run_id));Sourcepub fn step_id(&self) -> Option<Uuid>
pub fn step_id(&self) -> Option<Uuid>
Returns the step this event belongs to, if any.
Only StepCompleted,
StepFailed,
ApprovalRequested and
ApprovalEscalated always carry a step
identifier; ApprovalGranted and
ApprovalRejected carry one when it was
recorded; every other variant returns None.
§Examples
use ironflow_engine::notify::{Event, StepFailedEvent};
use ironflow_store::models::StepKind;
use uuid::Uuid;
use chrono::Utc;
let step_id = Uuid::now_v7();
let event = Event::StepFailed(StepFailedEvent {
run_id: Uuid::now_v7(),
step_id,
step_name: "build".to_string(),
kind: StepKind::Shell,
error: "exit code 1".to_string(),
at: Utc::now(),
});
assert_eq!(event.step_id(), Some(step_id));Sourcepub fn user_id(&self) -> Option<Uuid>
pub fn user_id(&self) -> Option<Uuid>
Returns the user this event belongs to, if any.
Only the auth events (UserSignedIn,
UserSignedUp,
UserSignedOut) carry a user identifier;
every other variant returns None.
§Examples
use ironflow_engine::notify::{Event, UserSignedInEvent};
use uuid::Uuid;
use chrono::Utc;
let user_id = Uuid::now_v7();
let event = Event::UserSignedIn(UserSignedInEvent {
user_id,
username: "alice".to_string(),
at: Utc::now(),
});
assert_eq!(event.user_id(), Some(user_id));