pub struct GlobalEvent {
pub event_id: String,
pub event_type: String,
pub source: String,
pub timestamp: u64,
pub data: Value,
pub metadata: HashMap<String, String>,
}Expand description
全局事件类型
替代 AgentEvent 和 PluginEvent,提供全局事件抽象。
§事件类型
常见的事件类型包括:
lifecycle:*- 生命周期事件(created, initialized, started, stopped, shutdown)execution:*- 执行事件(started, completed, failed, interrupted)message:*- 消息事件(sent, received, delivered)plugin:*- 插件事件(loaded, unloaded, error)state:*- 状态变更事件(changed, error)custom:*- 自定义事件
Fields§
§event_id: String事件 ID(唯一标识)
event_type: String事件类型
使用命名空间格式,如 “lifecycle:initialized”
source: String事件源(触发事件的 Agent 或组件 ID)
timestamp: u64时间戳(毫秒)
data: Value事件数据(负载)
metadata: HashMap<String, String>元数据(额外属性)
Implementations§
Source§impl GlobalEvent
impl GlobalEvent
Sourcepub fn get_data<T: for<'de> Deserialize<'de>>(&self) -> Option<T>
pub fn get_data<T: for<'de> Deserialize<'de>>(&self) -> Option<T>
获取特定数据字段
Sourcepub fn matches_prefix(&self, prefix: &str) -> bool
pub fn matches_prefix(&self, prefix: &str) -> bool
检查事件类型是否匹配前缀
Trait Implementations§
Source§impl Clone for GlobalEvent
impl Clone for GlobalEvent
Source§fn clone(&self) -> GlobalEvent
fn clone(&self) -> GlobalEvent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GlobalEvent
impl Debug for GlobalEvent
Source§impl<'de> Deserialize<'de> for GlobalEvent
impl<'de> Deserialize<'de> for GlobalEvent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for GlobalEvent
impl RefUnwindSafe for GlobalEvent
impl Send for GlobalEvent
impl Sync for GlobalEvent
impl Unpin for GlobalEvent
impl UnsafeUnpin for GlobalEvent
impl UnwindSafe for GlobalEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more