1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! [`EventSubscriber`] trait -- react to domain events.
use Future;
use Pin;
use Event;
/// Boxed future returned by [`EventSubscriber::handle`].
pub type SubscriberFuture<'a> = ;
/// A subscriber that reacts to domain events.
///
/// Implement this trait to create custom notification channels (Slack,
/// Discord, PagerDuty, etc.). The engine broadcasts events to all
/// registered subscribers via [`EventPublisher`](super::EventPublisher).
///
/// # Contract
///
/// - [`handle`](EventSubscriber::handle) is called only for events that
/// match the filter configured at subscription time.
/// - Implementations must not block -- heavy work should be spawned.
/// - Errors are logged internally; they must not propagate.
///
/// # Examples
///
/// ```no_run
/// use ironflow_engine::notify::{EventSubscriber, Event, SubscriberFuture};
///
/// struct LogSubscriber;
///
/// impl EventSubscriber for LogSubscriber {
/// fn name(&self) -> &str { "log" }
///
/// fn handle<'a>(&'a self, event: &'a Event) -> SubscriberFuture<'a> {
/// Box::pin(async move {
/// println!("[{}] {:?}", event.event_type(), event);
/// })
/// }
/// }
/// ```