pub struct EventQueueManager { /* private fields */ }Expand description
Manages event queues for active tasks.
Each task can have at most one active writer. When a client subscribes (or resubscribes), the manager returns the existing writer and a fresh reader, or creates both if none exists.
Implementations§
Source§impl EventQueueManager
impl EventQueueManager
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new, empty event queue manager with default capacity.
§Examples
use a2a_protocol_server::EventQueueManager;
let manager = EventQueueManager::new();Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new event queue manager with the specified channel capacity.
Sourcepub const fn with_max_event_size(self, max_event_size: usize) -> Self
pub const fn with_max_event_size(self, max_event_size: usize) -> Self
Creates a new event queue manager with the specified maximum event size.
Events exceeding this size (in serialized bytes) will be rejected with an error to prevent OOM conditions.
Sourcepub const fn with_max_concurrent_queues(self, max: usize) -> Self
pub const fn with_max_concurrent_queues(self, max: usize) -> Self
Sets the maximum number of concurrent event queues.
When the limit is reached, new queue creation will return an error
reader (None) to signal capacity exhaustion.
Sourcepub async fn get_or_create(
&self,
task_id: &TaskId,
) -> (Arc<InMemoryQueueWriter>, Option<InMemoryQueueReader>)
pub async fn get_or_create( &self, task_id: &TaskId, ) -> (Arc<InMemoryQueueWriter>, Option<InMemoryQueueReader>)
Returns the writer for the given task, creating a new queue if none exists.
If a queue already exists, the returned reader is None (the original
reader was given out at creation time). If a new queue is created, both
the writer and reader are returned.
If max_concurrent_queues is set and the limit is reached, returns
the writer with None reader (same as existing queue case).
Sourcepub async fn destroy(&self, task_id: &TaskId)
pub async fn destroy(&self, task_id: &TaskId)
Removes and drops the event queue for the given task.
Sourcepub async fn active_count(&self) -> usize
pub async fn active_count(&self) -> usize
Returns the number of active event queues.
Sourcepub async fn destroy_all(&self)
pub async fn destroy_all(&self)
Removes all event queues, causing all readers to see EOF.
Trait Implementations§
Source§impl Clone for EventQueueManager
impl Clone for EventQueueManager
Source§fn clone(&self) -> EventQueueManager
fn clone(&self) -> EventQueueManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more