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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright (c) 2026 Kirky.X🌠
// SPDX-License-Identifier: MIT
//! 事件系统模块
//!
//! 提供事件发布/订阅系统,支持事件发射、分发和 Webhook 推送。
//!
//! # 功能
//!
//! - 事件发射器 (EventEmitter): 使用 tokio broadcast channel 实现事件发布
//! - 事件分发器 (EventDispatcher): 监听事件并分发给处理器和 Webhook
//! - 事件类型 (EventType): 预定义的系统事件类型
//! - 事件处理器 (EventHandler): 可扩展的事件处理接口
//!
//! # 示例
//!
//! ```rust
//! use limiteron::{EventEmitter, EventDispatcher, Event, EventType};
//!
//! #[tokio::main]
//! async fn main() {
//! // 创建事件发射器
//! let emitter = EventEmitter::with_default_config();
//!
//! // 创建分发器并启动
//! let dispatcher = EventDispatcher::new(emitter.clone());
//! dispatcher.start().await;
//!
//! // 发射事件
//! let event = Event::new(EventType::RateLimitTriggered {
//! key: "192.168.1.1".to_string(),
//! rule_id: "rule_1".to_string(),
//! decision: "Deny".to_string(),
//! });
//! emitter.emit(event).await.unwrap();
//!
//! // 停止分发器
//! dispatcher.stop().await;
//! }
//! ```
//!
//! # 事件类型
//!
//! | 事件类型 | 描述 | 严重级别 |
//! |---------|------|---------|
//! | `RateLimitTriggered` | 限流触发 | 2-6 |
//! | `BanApplied` | 封禁应用 | 8 |
//! | `BanExpired` | 封禁过期 | 1 |
//! | `CircuitStateChanged` | 熔断器状态变更 | 1-9 |
//! | `QuotaAlert` | 配额告警 | 3-7 |
// 子模块
// 事件 Outbox:封禁/配额事件 outbox 表化(需 DB 后端 feature)
pub
// 封禁跨实例同步:经 oxcache Pub/Sub 广播封禁变更
pub
// Webhook 外发签名:HMAC-SHA256 签名头 + 时间戳防重放。
// 公开导出经 lib.rs 根(本模块为私有 mod)。
pub
// Re-export all public types
pub use EventDispatcher;
pub use EventEmitter;
pub use ;
pub use ;
pub use ;