pub struct EventEmitter { /* private fields */ }Expand description
Event emitter for a single node
Handles event creation, policy enforcement, and priority queuing.
Events with PropagationMode::Local are stored locally and not queued
for transmission.
Implementations§
Source§impl EventEmitter
impl EventEmitter
Sourcepub fn new(node_id: String, formation_id: String) -> Self
pub fn new(node_id: String, formation_id: String) -> Self
Create a new event emitter for a node
Sourcepub fn emit(&self, event: PeatEvent) -> Result<()>
pub fn emit(&self, event: PeatEvent) -> Result<()>
Emit an event with automatic routing based on policy
Events are routed according to their AggregationPolicy:
PropagationMode::Local: Stored locally, not transmittedPropagationMode::Query: Stored locally for query accessPropagationMode::SummaryorFull: Queued for transmission
Sourcepub fn emit_new(
&self,
event_class: EventClass,
event_type: String,
routing: AggregationPolicy,
payload_type_url: String,
payload_value: Vec<u8>,
source_instance_id: Option<String>,
) -> Result<String>
pub fn emit_new( &self, event_class: EventClass, event_type: String, routing: AggregationPolicy, payload_type_url: String, payload_value: Vec<u8>, source_instance_id: Option<String>, ) -> Result<String>
Create and emit an event with the given parameters
Automatically generates event_id and timestamp.
Sourcepub fn emit_product(
&self,
product_type: &str,
payload: Vec<u8>,
propagation: PropagationMode,
priority: EventPriority,
) -> Result<String>
pub fn emit_product( &self, product_type: &str, payload: Vec<u8>, propagation: PropagationMode, priority: EventPriority, ) -> Result<String>
Emit a product event (output from software processing)
Products are the primary output events from software instances.
Sourcepub fn emit_telemetry(
&self,
metric_name: &str,
payload: Vec<u8>,
) -> Result<String>
pub fn emit_telemetry( &self, metric_name: &str, payload: Vec<u8>, ) -> Result<String>
Emit a telemetry event (metrics, health, diagnostics)
Telemetry defaults to Query propagation (stored locally, queryable)
Sourcepub fn emit_anomaly(
&self,
anomaly_type: &str,
payload: Vec<u8>,
) -> Result<String>
pub fn emit_anomaly( &self, anomaly_type: &str, payload: Vec<u8>, ) -> Result<String>
Emit an anomaly event (unusual patterns, alerts)
Anomalies default to Full propagation with High priority
Sourcepub fn emit_critical(
&self,
event_type: &str,
payload: Vec<u8>,
) -> Result<String>
pub fn emit_critical( &self, event_type: &str, payload: Vec<u8>, ) -> Result<String>
Emit a critical event (immediate attention required)
Critical events have CRITICAL priority and Full propagation
Sourcepub fn pop_critical(&self) -> Vec<PeatEvent>
pub fn pop_critical(&self) -> Vec<PeatEvent>
Pop all critical events for immediate transmission
Sourcepub fn pop_events(&self, max_events: usize) -> Vec<PeatEvent>
pub fn pop_events(&self, max_events: usize) -> Vec<PeatEvent>
Pop events for transmission using weighted fair queuing
Sourcepub fn has_critical(&self) -> bool
pub fn has_critical(&self) -> bool
Check if there are critical events pending
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Get count of pending outbound events
Sourcepub fn local_count(&self) -> usize
pub fn local_count(&self) -> usize
Get count of locally stored events
Sourcepub fn query_local(&self, event_type: Option<&str>) -> Vec<PeatEvent>
pub fn query_local(&self, event_type: Option<&str>) -> Vec<PeatEvent>
Query locally stored events by event type
Sourcepub fn get_local(&self, event_id: &str) -> Option<PeatEvent>
pub fn get_local(&self, event_id: &str) -> Option<PeatEvent>
Get a specific locally stored event by ID
Sourcepub fn formation_id(&self) -> &str
pub fn formation_id(&self) -> &str
Get the formation ID
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EventEmitter
impl RefUnwindSafe for EventEmitter
impl Send for EventEmitter
impl Sync for EventEmitter
impl Unpin for EventEmitter
impl UnsafeUnpin for EventEmitter
impl UnwindSafe for EventEmitter
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
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>
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>
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 more