pub struct EventManager {
groups: Mutex<HashMap<GroupId, Vec<u32>>>,
sessions: Mutex<HashMap<SessionId, Vec<u32>>>,
named_groups: Mutex<HashMap<String, Vec<u32>>>,
configs: Mutex<HashMap<u32, DeliveryConfig>>,
task_filters: Mutex<HashMap<u32, Vec<(usize, EventFilter)>>>,
next_event_id: Mutex<u64>,
channels: Mutex<HashMap<String, Arc<EventChannelObject>>>,
}Expand description
Event Manager - Main implementation of the event system
Fields§
§groups: Mutex<HashMap<GroupId, Vec<u32>>>Task group memberships
sessions: Mutex<HashMap<SessionId, Vec<u32>>>Session memberships
named_groups: Mutex<HashMap<String, Vec<u32>>>Named/custom group memberships
configs: Mutex<HashMap<u32, DeliveryConfig>>Delivery configurations per task
task_filters: Mutex<HashMap<u32, Vec<(usize, EventFilter)>>>Task-specific event filters (handler_id, filter)
next_event_id: Mutex<u64>Next event ID
channels: Mutex<HashMap<String, Arc<EventChannelObject>>>Channel registry - EventManager only manages channels, channels manage their own subscriptions
Implementations§
Source§impl EventManager
impl EventManager
Sourcepub fn get_manager() -> &'static EventManager
pub fn get_manager() -> &'static EventManager
Get the global EventManager instance
Sourcefn get_current_task_id(&self) -> Option<u32>
fn get_current_task_id(&self) -> Option<u32>
Helper: get the currently running task id, if available
Sourcepub fn create_channel(&self, name: String) -> KernelObject
pub fn create_channel(&self, name: String) -> KernelObject
Create or get an event channel as a KernelObject handle
This method creates an EventChannel that can be inserted into a HandleTable, providing consistent resource management with other kernel objects.
Sourcepub fn create_subscription(
&self,
channel_name: String,
task_id: u32,
) -> Result<KernelObject, EventError>
pub fn create_subscription( &self, channel_name: String, task_id: u32, ) -> Result<KernelObject, EventError>
Create a subscription to a channel as a KernelObject handle
This method creates an EventSubscription that can be inserted into a HandleTable, allowing tasks to receive events through the standard handle interface.
Sourcepub fn send_event(&self, event: Event) -> Result<(), EventError>
pub fn send_event(&self, event: Event) -> Result<(), EventError>
Send an event
Sourcepub fn register_filter(
&self,
task_id: u32,
filter: EventFilter,
) -> Result<(), EventError>
pub fn register_filter( &self, task_id: u32, filter: EventFilter, ) -> Result<(), EventError>
Register an event filter for a task (without handler id)
Sourcepub fn register_filter_with_id(
&self,
task_id: u32,
handler_id: usize,
filter: EventFilter,
) -> Result<(), EventError>
pub fn register_filter_with_id( &self, task_id: u32, handler_id: usize, filter: EventFilter, ) -> Result<(), EventError>
Register an event filter for a task with explicit handler id
Sourcepub fn unregister_filter_by_id(
&self,
task_id: u32,
handler_id: usize,
) -> Result<(), EventError>
pub fn unregister_filter_by_id( &self, task_id: u32, handler_id: usize, ) -> Result<(), EventError>
Unregister a filter by handler id
Sourcepub fn get_filters_for_task(&self, task_id: u32) -> Vec<(usize, EventFilter)>
pub fn get_filters_for_task(&self, task_id: u32) -> Vec<(usize, EventFilter)>
Get a snapshot of filters for a task
Sourcepub fn clear_filters(&self, task_id: u32) -> Result<(), EventError>
pub fn clear_filters(&self, task_id: u32) -> Result<(), EventError>
Remove all filters for a task
Sourcepub fn subscribe_channel(&self, channel: &str) -> Result<(), EventError>
pub fn subscribe_channel(&self, channel: &str) -> Result<(), EventError>
Subscribe to a channel
Sourcepub fn unsubscribe_channel(&self, channel: &str) -> Result<(), EventError>
pub fn unsubscribe_channel(&self, channel: &str) -> Result<(), EventError>
Unsubscribe from a channel
Sourcepub fn join_group(&self, group_id: GroupId) -> Result<(), EventError>
pub fn join_group(&self, group_id: GroupId) -> Result<(), EventError>
Join a task group
Sourcepub fn leave_group(&self, group_id: GroupId) -> Result<(), EventError>
pub fn leave_group(&self, group_id: GroupId) -> Result<(), EventError>
Leave a task group
Sourcepub fn join_session(&self, session_id: SessionId) -> Result<(), EventError>
pub fn join_session(&self, session_id: SessionId) -> Result<(), EventError>
Join a session group
Sourcepub fn leave_session(&self, session_id: SessionId) -> Result<(), EventError>
pub fn leave_session(&self, session_id: SessionId) -> Result<(), EventError>
Leave a session group
Sourcepub fn join_named_group(&self, name: String) -> Result<(), EventError>
pub fn join_named_group(&self, name: String) -> Result<(), EventError>
Join a named/custom group
Sourcepub fn leave_named_group(&self, name: &str) -> Result<(), EventError>
pub fn leave_named_group(&self, name: &str) -> Result<(), EventError>
Leave a named/custom group
Sourcepub fn configure_delivery(
&self,
config: DeliveryConfig,
) -> Result<(), EventError>
pub fn configure_delivery( &self, config: DeliveryConfig, ) -> Result<(), EventError>
Configure delivery settings
Sourcefn get_task_config_or_default(&self, task_id: u32) -> DeliveryConfig
fn get_task_config_or_default(&self, task_id: u32) -> DeliveryConfig
Get a task’s delivery configuration or the default if none is set
Sourcefn handle_delivery_failure(
&self,
sender: Option<u32>,
err: &EventError,
event: &Event,
)
fn handle_delivery_failure( &self, sender: Option<u32>, err: &EventError, event: &Event, )
Handle delivery failures according to the sender’s configured policy
Sourcefn deliver_direct(
&self,
event: Event,
target: TaskId,
_priority: EventPriority,
_reliable: bool,
) -> Result<(), EventError>
fn deliver_direct( &self, event: Event, target: TaskId, _priority: EventPriority, _reliable: bool, ) -> Result<(), EventError>
Deliver direct event to specific task
Sourcefn deliver_to_channel(
&self,
event: Event,
channel_id: &str,
create_if_missing: bool,
_priority: EventPriority,
) -> Result<(), EventError>
fn deliver_to_channel( &self, event: Event, channel_id: &str, create_if_missing: bool, _priority: EventPriority, ) -> Result<(), EventError>
Deliver to channel subscribers
Sourcefn deliver_to_group(
&self,
event: Event,
group_target: &GroupTarget,
_priority: EventPriority,
_reliable: bool,
) -> Result<(), EventError>
fn deliver_to_group( &self, event: Event, group_target: &GroupTarget, _priority: EventPriority, _reliable: bool, ) -> Result<(), EventError>
Deliver to group members
Sourcefn deliver_broadcast(
&self,
event: Event,
_priority: EventPriority,
_reliable: bool,
) -> Result<(), EventError>
fn deliver_broadcast( &self, event: Event, _priority: EventPriority, _reliable: bool, ) -> Result<(), EventError>
Deliver broadcast event to all tasks
Sourcepub fn deliver_to_task(
&self,
task_id: u32,
event: Event,
) -> Result<(), EventError>
pub fn deliver_to_task( &self, task_id: u32, event: Event, ) -> Result<(), EventError>
Deliver event to a specific task
Sourcepub fn dequeue_event_for_task(&self, task_id: u32) -> Option<Event>
👎Deprecated: Use Task.process_pending_events() instead
pub fn dequeue_event_for_task(&self, task_id: u32) -> Option<Event>
Dequeue the next highest priority event for a task This method is deprecated - tasks now process events directly via process_pending_events()
Sourcepub fn get_pending_event_count(&self, task_id: u32) -> usize
pub fn get_pending_event_count(&self, task_id: u32) -> usize
Get the number of pending events for a task
Sourcepub fn has_pending_events(&self, task_id: u32) -> bool
pub fn has_pending_events(&self, task_id: u32) -> bool
Check if a task has any pending events
Sourcepub fn get_channel(&self, name: &str) -> Option<Arc<EventChannelObject>>
pub fn get_channel(&self, name: &str) -> Option<Arc<EventChannelObject>>
Get a channel by name, if it exists.
Sourcepub fn remove_subscription_from_channel(
&self,
channel_name: &str,
subscription_id: &str,
) -> Result<(), EventError>
pub fn remove_subscription_from_channel( &self, channel_name: &str, subscription_id: &str, ) -> Result<(), EventError>
Remove a subscription from a channel by name and subscription id.