pub struct MessageQueue { /* private fields */ }Expand description
Thread-safe message queue with steering semantics.
Messages are enqueued with a SteeringMode that determines how they
interact with an active run. The queue supports priority-based ordering
and safe preemption at tool boundaries.
Implementations§
Source§impl MessageQueue
impl MessageQueue
Sourcepub fn new(config: QueueConfig) -> Self
pub fn new(config: QueueConfig) -> Self
Create a new message queue with the given configuration.
Sourcepub fn enqueue(&self, message: QueuedMessage) -> Result<(), QueueError>
pub fn enqueue(&self, message: QueuedMessage) -> Result<(), QueueError>
Enqueue a message. Returns error if queue is full.
Sourcepub fn remove(&self, id: &str) -> Result<QueuedMessage, QueueError>
pub fn remove(&self, id: &str) -> Result<QueuedMessage, QueueError>
Remove a specific queued message by ID.
Sourcepub fn status(&self) -> Result<QueueStatus, QueueError>
pub fn status(&self) -> Result<QueueStatus, QueueError>
Get a snapshot of the current queue state.
Sourcepub fn set_active_run(&self, active: bool) -> Result<(), QueueError>
pub fn set_active_run(&self, active: bool) -> Result<(), QueueError>
Mark that an active run has started.
Sourcepub fn has_active_run(&self) -> Result<bool, QueueError>
pub fn has_active_run(&self) -> Result<bool, QueueError>
Whether there is an active run.
Sourcepub fn check_preemption(&self) -> Result<SteeringAction, QueueError>
pub fn check_preemption(&self) -> Result<SteeringAction, QueueError>
Check for preemption at a tool boundary.
Inspects the queue for Interrupt or Steer messages and returns
the appropriate SteeringAction. Priority: interrupt > steer.
Sourcepub fn drain_after_run(&self) -> Result<Vec<QueuedMessage>, QueueError>
pub fn drain_after_run(&self) -> Result<Vec<QueuedMessage>, QueueError>
Drain messages after a run completes, in priority order.
Returns messages ordered: followup first (same context), then collect (fresh runs). Collect messages within the coalesce window are batched together.
Sourcepub fn health_check(&self) -> Result<Vec<String>, QueueError>
pub fn health_check(&self) -> Result<Vec<String>, QueueError>
Check queue health for heartbeat integration.
Sourcepub fn depth(&self) -> Result<usize, QueueError>
pub fn depth(&self) -> Result<usize, QueueError>
Current queue depth.
Sourcepub fn config(&self) -> &QueueConfig
pub fn config(&self) -> &QueueConfig
Get a reference to the queue config.
Trait Implementations§
Source§impl Clone for MessageQueue
impl Clone for MessageQueue
Source§impl PreemptionCheck for MessageQueue
impl PreemptionCheck for MessageQueue
Source§fn check_preemption(&self) -> Result<SteeringAction, QueueError>
fn check_preemption(&self) -> Result<SteeringAction, QueueError>
SteeringAction indicating what should happen next.