pub struct ExtensionState { /* private fields */ }Expand description
Shared state for extension management.
This manages all registered extensions, their event queues, and coordination for event delivery.
Implementations§
Source§impl ExtensionState
impl ExtensionState
Sourcepub async fn broadcast_event(&self, event: LifecycleEvent)
pub async fn broadcast_event(&self, event: LifecycleEvent)
Broadcasts an event to all extensions subscribed to that event type.
§Arguments
event- The lifecycle event to broadcast
Sourcepub async fn next_event(&self, extension_id: &str) -> Option<LifecycleEvent>
pub async fn next_event(&self, extension_id: &str) -> Option<LifecycleEvent>
Sourcepub async fn get_extension(
&self,
extension_id: &str,
) -> Option<RegisteredExtension>
pub async fn get_extension( &self, extension_id: &str, ) -> Option<RegisteredExtension>
Sourcepub async fn get_all_extensions(&self) -> Vec<RegisteredExtension>
pub async fn get_all_extensions(&self) -> Vec<RegisteredExtension>
Gets all registered extensions.
Sourcepub async fn extension_count(&self) -> usize
pub async fn extension_count(&self) -> usize
Returns the number of registered extensions.
Sourcepub async fn get_invoke_subscribers(&self) -> Vec<ExtensionId> ⓘ
pub async fn get_invoke_subscribers(&self) -> Vec<ExtensionId> ⓘ
Returns the IDs of all extensions subscribed to INVOKE events.
This is used to determine which extensions need to signal readiness after each invocation.
Sourcepub async fn get_shutdown_subscribers(&self) -> Vec<ExtensionId> ⓘ
pub async fn get_shutdown_subscribers(&self) -> Vec<ExtensionId> ⓘ
Returns the IDs of all extensions subscribed to SHUTDOWN events.
This is used to determine which extensions need to receive the SHUTDOWN event during graceful shutdown.
Sourcepub async fn wake_all_extensions(&self)
pub async fn wake_all_extensions(&self)
Wakes all extensions waiting on /next.
This is used during shutdown to unblock extensions waiting for events.
Sourcepub async fn is_queue_empty(&self, extension_id: &str) -> bool
pub async fn is_queue_empty(&self, extension_id: &str) -> bool
Checks if an extension’s event queue is empty.
This is used during shutdown to determine if an extension has consumed all events (including the SHUTDOWN event).
Sourcepub async fn mark_shutdown_acknowledged(&self, extension_id: &str)
pub async fn mark_shutdown_acknowledged(&self, extension_id: &str)
Marks an extension as having acknowledged shutdown.
This is called when an extension polls /next after receiving the
SHUTDOWN event, signaling it has completed its cleanup work.
Sourcepub async fn is_shutdown_acknowledged(&self, extension_id: &str) -> bool
pub async fn is_shutdown_acknowledged(&self, extension_id: &str) -> bool
Checks if an extension has acknowledged shutdown.
Sourcepub async fn wait_for_shutdown_acknowledged(&self, extension_ids: &[String])
pub async fn wait_for_shutdown_acknowledged(&self, extension_ids: &[String])
Waits for all specified extensions to acknowledge shutdown.
Returns when all extensions have polled /next after receiving SHUTDOWN.
Sourcepub async fn clear_shutdown_acknowledged(&self)
pub async fn clear_shutdown_acknowledged(&self)
Clears shutdown acknowledgment state.
Called when starting a new shutdown sequence.