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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! Connects best-effort runtime events to application observers.
//!
//! Register [`Subscribe`] implementations through
//! [`SupervisorBuilder::with_subscribers`](crate::SupervisorBuilder::with_subscribers).
//! Implement the trait for metrics, alerts, or application-specific output.
//! Enable the `logging` feature for `LogWriter` or the `tracing` feature for `TracingBridge`.
//! Every configured subscriber receives its own bounded, serial callback lane.
//!
//! ```text
//! ordinary runtime components
//! │ Event
//! ▼
//! bounded event bus
//! ▼
//! runtime event relay
//! ▼
//! SubscriberSet
//! ├── queue A ──► serial lane A ──► subscriber A::on_event
//! └── queue B ──► serial lane B ──► subscriber B::on_event
//!
//! internal diagnostics ──► event relay or subscriber lane ──► callbacks
//! ```
//!
//! Internal subscriber diagnostics can bypass the shared bus.
//! Subscriber delivery is for logs, metrics, alerts, and diagnostics.
//! It does not own registry state or watched task outcomes.
//! Publishing an ordinary event never calls subscriber code.
//! Events can be lost at the shared bus or at an individual subscriber queue.
//! Each subscriber queue has its own capacity and ordinary-event loss count.
//! A blocked callback on the shared worker can delay other shared lanes until their queues fill.
//!
//! Each lane preserves FIFO callback order.
//! Short callbacks use one fixed shared worker by default.
//! [`SubscriberExecution::Dedicated`] assigns one lane its own worker when blocking isolation is required.
//! `LogWriter` and the tracing bridges select dedicated execution because their output sinks run synchronously.
//! Shutdown gives all lanes one shared drain deadline.
//! With no configured subscribers, the event bus stays disabled and no event relay or callback worker starts.
//!
//! Shared ingress and subscriber queues have separate capacities.
//! Use [`SupervisorConfig::with_bus_capacity`](crate::SupervisorConfig::with_bus_capacity) for bursts before fan-out.
//! Override [`Subscribe::queue_capacity`] for bursts in one observer, and keep its callback short.
//! Larger queues absorb longer bursts but consume more memory.
//!
//! # Choosing an observer
//!
//! | Need | Observer |
//! |---------------------------------------|----------------------------------|
//! | Quick human-readable console output | `LogWriter` with `logging` |
//! | Structured fields in `tracing` | `TracingBridge` with `tracing` |
//! | Metrics, alerts, or another transport | A custom [`Subscribe`] type |
//!
//! Use [`TaskWaiter`](crate::TaskWaiter) instead when application logic needs a watched task's final result.
//! Subscriber delivery is intentionally lossy.
pub use ;
pub use SubscriberSet;
pub use LogWriter;
pub use ;