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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.