pub struct WorkQueue { /* private fields */ }Expand description
In-memory work queue with priority-based atomic claim.
Implementations§
Source§impl WorkQueue
impl WorkQueue
Sourcepub fn new(config: WorkQueueConfig) -> Self
pub fn new(config: WorkQueueConfig) -> Self
Create a new work queue.
Sourcepub fn enqueue(
&self,
work_type: impl Into<String>,
payload: Value,
priority: i32,
) -> String
pub fn enqueue( &self, work_type: impl Into<String>, payload: Value, priority: i32, ) -> String
Enqueue a new work item. Returns its ID.
Sourcepub fn claim(
&self,
agent_id: &str,
work_type_filter: Option<&[String]>,
) -> Option<WorkItem>
pub fn claim( &self, agent_id: &str, work_type_filter: Option<&[String]>, ) -> Option<WorkItem>
Atomically claim the highest-priority pending item.
If work_type_filter is provided, only items of those types are considered.
Returns None if no items are available.
Sourcepub fn complete(&self, item_id: &str, result: WorkResult) -> SdkResult<()>
pub fn complete(&self, item_id: &str, result: WorkResult) -> SdkResult<()>
Mark item as completed with result.
Sourcepub fn list(&self, filter: Option<WorkStatus>) -> Vec<WorkItem>
pub fn list(&self, filter: Option<WorkStatus>) -> Vec<WorkItem>
List items, optionally filtered by status.
Sourcepub fn stats(&self) -> WorkQueueStats
pub fn stats(&self) -> WorkQueueStats
Get queue statistics.
Auto Trait Implementations§
impl !Freeze for WorkQueue
impl !RefUnwindSafe for WorkQueue
impl !UnwindSafe for WorkQueue
impl Send for WorkQueue
impl Sync for WorkQueue
impl Unpin for WorkQueue
impl UnsafeUnpin for WorkQueue
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
Mutably borrows from an owned value. Read more