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//! - [`MessageFormatter`] -- trait: converts events into platform-specific messages.
19//! - [`RetryConfig`] -- shared retry/backoff configuration for HTTP subscribers.
20//! - [`WebhookSubscriber`] -- built-in HTTP POST implementation.
21//!
22//! # Examples
23//!
24//! ```no_run
25//! use ironflow_engine::notify::{Event, EventPublisher, WebhookSubscriber};
26//!
27//! let mut publisher = EventPublisher::new();
28//! publisher.subscribe(
29//! WebhookSubscriber::new("https://hooks.example.com/events"),
30//! &[Event::RUN_STATUS_CHANGED, Event::STEP_FAILED],
31//! );
32//! ```
33
34mod betterstack;
35mod event;
36mod formatter;
37mod publisher;
38mod retry;
39mod subscriber;
40mod webhook;
41
42pub use betterstack::BetterStackSubscriber;
43pub use event::Event;
44pub use formatter::{FormattedMessage, MessageFormatter};
45pub use publisher::EventPublisher;
46pub use retry::{RetryConfig, deliver_with_retry, is_accepted_202, is_success_2xx};
47pub use subscriber::{EventSubscriber, SubscriberFuture};
48pub use webhook::WebhookSubscriber;