pub trait Subscribe:
Send
+ Sync
+ 'static {
// Required method
fn on_event<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 Event,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn name(&self) -> &'static str { ... }
fn queue_capacity(&self) -> usize { ... }
}Expand description
Event subscriber for runtime observability.
Each subscriber runs in isolation:
- Bounded queue buffers events (capacity via
Self::queue_capacity). - Dedicated worker task processes events sequentially (FIFO).
- Panic isolation: panics are caught and published as
SubscriberPanicked.
§Implementation requirements
- Use async I/O; avoid blocking the executor.
- Handle errors internally; do not panic.
- Slow processing affects only this subscriber’s queue.
Required Methods§
Sourcefn on_event<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 Event,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_event<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 Event,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Processes a single event.
Called from a dedicated worker task, not in the publisher context. Events are delivered in FIFO order per subscriber.
Panics are caught; the runtime publishes EventKind::SubscriberPanicked.
Provided Methods§
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
Returns the subscriber name used in logs/metrics and overflow/panic events.
Prefer short, descriptive names (e.g., “metrics”, “audit”, “slack”).
The default uses type_name::<Self>(), which can be verbose - override it when possible.
Sourcefn queue_capacity(&self) -> usize
fn queue_capacity(&self) -> usize
Returns the preferred queue capacity for this subscriber.
Overflow behavior:
- The new event is dropped for this subscriber only,
- an
EventKind::SubscriberOverflowis published, - other subscribers are unaffected.
The runtime clamps capacity to a minimum of 1.
Default: 1024.