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 with_data(self, data: impl Into<Value>) -> GlobalEvent
pub fn with_data(self, data: impl Into<Value>) -> GlobalEvent
创建带数据的事件
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> GlobalEvent
pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> GlobalEvent
添加元数据
Sourcepub fn get_data<T>(&self) -> Option<T>where
T: for<'de> Deserialize<'de>,
pub fn get_data<T>(&self) -> Option<T>where
T: for<'de> Deserialize<'de>,
获取特定数据字段
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<GlobalEvent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<GlobalEvent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for GlobalEvent
impl Serialize for GlobalEvent
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Message for T
impl<T> Message for T
Source§fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
Convert a BoxedMessage to this concrete type
Source§fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
Convert this message to a BoxedMessage