Skip to main content

anycms_event/
lib.rs

1//! # anycms-event
2//!
3//! A thread-safe, async event bus system for AnyCMS built on tokio broadcast channels.
4//!
5//! ## Quick Start
6//!
7//! ```ignore
8//! use anycms_event::prelude::*;
9//!
10//! #[derive(Clone, Debug, Serialize, Deserialize)]
11//! struct UserCreated {
12//!     user_id: u64,
13//!     name: String,
14//! }
15//!
16//! impl Event for UserCreated {
17//!     fn event_name() -> &'static str { "user.created" }
18//! }
19//!
20//! #[tokio::main]
21//! async fn main() {
22//!     let bus = EventBus::new();
23//!
24//!     bus.subscribe(|event: UserCreated| async move {
25//!         println!("User created: {}", event.name);
26//!         Ok(())
27//!     }).await.unwrap();
28//!
29//!     bus.publish(UserCreated { user_id: 1, name: "Alice".into() }).await.unwrap();
30//! }
31//! ```
32
33pub mod error;
34pub mod event;
35pub mod bus;
36pub mod topic;
37pub mod telemetry;
38pub mod builder;
39pub mod registry;
40pub mod execution_log;
41pub mod trigger;
42pub mod transport;
43
44#[cfg(feature = "prometheus")]
45pub mod telemetry_metrics;
46
47pub mod prelude;
48
49// Re-export main types at crate root
50pub use error::{EventBusError, Result};
51pub use event::Event;
52pub use bus::EventBus;
53pub use trigger::RuleStorage;
54
55#[cfg(feature = "prometheus")]
56pub use telemetry_metrics::MetricsTelemetry;
57
58#[cfg(feature = "testing")]
59pub mod testing;
60
61// Re-export proc macros from derive crate
62pub use anycms_event_derive::{Event, event_bus};