Skip to main content

ironflow_engine/notify/
mod.rs

1//! Event-driven notification system for the ironflow lifecycle.
2//!
3//! Uses a publisher/subscriber pattern: the [`EventPublisher`] broadcasts
4//! [`Event`]s to registered [`EventSubscriber`]s. Event type filtering
5//! is handled by the publisher at subscription time -- subscribers only
6//! receive events they signed up for.
7//!
8//! Built-in subscribers:
9//! - [`WebhookSubscriber`] -- POSTs JSON to a URL with retry and exponential backoff.
10//! - [`BetterStackSubscriber`] -- forwards error events to BetterStack Logs.
11//!
12//! # Architecture
13//!
14//! - [`Event`] -- domain event enum covering runs, steps, approvals, auth.
15//! - [`EventSubscriber`] -- trait: receives and handles a single event.
16//! - [`EventPublisher`] -- holds subscriptions (subscriber + event type filter),
17//!   dispatches matching events via `tokio::spawn`.
18//! - [`WebhookSubscriber`] -- built-in HTTP POST implementation.
19//!
20//! # Examples
21//!
22//! ```no_run
23//! use ironflow_engine::notify::{Event, EventPublisher, WebhookSubscriber};
24//!
25//! let mut publisher = EventPublisher::new();
26//! publisher.subscribe(
27//!     WebhookSubscriber::new("https://hooks.example.com/events"),
28//!     &[Event::RUN_STATUS_CHANGED, Event::STEP_FAILED],
29//! );
30//! ```
31
32mod betterstack;
33mod event;
34mod publisher;
35mod subscriber;
36mod webhook;
37
38pub use betterstack::BetterStackSubscriber;
39pub use event::Event;
40pub use publisher::EventPublisher;
41pub use subscriber::{EventSubscriber, SubscriberFuture};
42pub use webhook::WebhookSubscriber;