pub trait EventSubscriber: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn handle<'a>(&'a self, event: &'a Event) -> SubscriberFuture<'a>;
}Expand description
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.
§Contract
handleis 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
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);
})
}
}Required Methods§
Sourcefn handle<'a>(&'a self, event: &'a Event) -> SubscriberFuture<'a>
fn handle<'a>(&'a self, event: &'a Event) -> SubscriberFuture<'a>
Handle a domain event.
Only called for events matching the filter set at subscription time. The subscriber does not need to filter.