tenzro_events/lib.rs
1//! Real-time event streaming, subscriptions, and webhook delivery for Tenzro Network
2//!
3//! This crate provides a unified event model across all VMs and subsystems
4//! with monotonic sequencing, cursor-based replay, and rich filtering.
5//!
6//! # Architecture
7//!
8//! ```text
9//! VM Executors / Consensus / Token / Identity
10//! | in-process callbacks
11//! v
12//! EventBus (ring buffer, broadcast channels)
13//! +-- Subscribers (unfiltered or filtered)
14//! +-- Future: gRPC, WebSocket, Webhook, Persistence
15//! ```
16
17pub mod types;
18pub mod bus;
19
20// Re-export commonly used types
21pub use types::{
22 TenzroEvent, EventEnvelope, EventFilter, EventType, VmType,
23 SubscriptionId, SubscriptionConfig, event_type_name,
24};
25pub use bus::{
26 EventBus, EventBusConfig, EventBusStats, EventBusError,
27 EventSubscriber, FilteredEventSubscriber, StatsSnapshot,
28};
29
30/// Event streaming crate version
31pub const VERSION: &str = env!("CARGO_PKG_VERSION");
32
33/// Default event bus capacity (number of events in ring buffer)
34pub const DEFAULT_BUS_CAPACITY: usize = 65536;
35
36/// Default event store retention (7 days in seconds)
37pub const DEFAULT_RETENTION_SECS: u64 = 604_800;
38
39/// RocksDB column family for event storage
40pub const CF_EVENTS: &str = "events";
41
42/// RocksDB column family for event index
43pub const CF_EVENT_INDEX: &str = "event_index";
44
45/// RocksDB column family for webhook configuration
46pub const CF_WEBHOOKS: &str = "webhooks";
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn test_version() {
54 assert!(!VERSION.is_empty());
55 }
56
57 #[test]
58 fn test_constants() {
59 assert_eq!(DEFAULT_BUS_CAPACITY, 65536);
60 assert_eq!(DEFAULT_RETENTION_SECS, 604_800);
61 }
62}