pub trait QueueStore {
Show 13 methods
// Required methods
fn push_job(&mut self, job: QueueJob) -> ThingdResult<QueueJob>;
fn claim_job_with_options(
&mut self,
queue: &str,
options: QueueClaimOptions,
) -> ThingdResult<Option<QueueJob>>;
fn ack_job(
&mut self,
queue: &str,
id: &str,
) -> ThingdResult<Option<QueueJob>>;
fn nack_job_with_options(
&mut self,
queue: &str,
id: &str,
options: QueueNackOptions,
) -> ThingdResult<Option<QueueJob>>;
fn list_jobs(&self, queue: &str) -> ThingdResult<Vec<QueueJob>>;
fn list_dead_jobs(&self, queue: &str) -> ThingdResult<Vec<QueueJob>>;
fn list_queues(&self) -> ThingdResult<Vec<String>>;
fn count_active_jobs(&self) -> ThingdResult<u64>;
fn count_dead_jobs(&self) -> ThingdResult<u64>;
// Provided methods
fn push_jobs_batch(
&mut self,
jobs: Vec<QueueJob>,
) -> ThingdResult<Vec<QueueJob>> { ... }
fn claim_job(&mut self, queue: &str) -> ThingdResult<Option<QueueJob>> { ... }
fn claim_and_ack(
&mut self,
queue: &str,
options: QueueClaimOptions,
) -> ThingdResult<Option<QueueJob>> { ... }
fn nack_job(
&mut self,
queue: &str,
id: &str,
) -> ThingdResult<Option<QueueJob>> { ... }
}Expand description
Queue storage operations.
§Examples
use thingd_core::{MemoryEngine, QueueStore, QueueJob, QueueJobStatus};
let mut store = MemoryEngine::new();
let job = QueueJob::new("emails", "job-1", r#"{"to":"alice@example.com"}"#, 3);
store.push_job(job).unwrap();
let claimed = store.claim_job("emails").unwrap();
assert!(claimed.is_some());
let job = claimed.unwrap();
assert_eq!(job.status, QueueJobStatus::Leased);
let completed = store.ack_job("emails", &job.id).unwrap();
assert_eq!(completed.unwrap().status, QueueJobStatus::Completed);Required Methods§
Sourcefn push_job(&mut self, job: QueueJob) -> ThingdResult<QueueJob>
fn push_job(&mut self, job: QueueJob) -> ThingdResult<QueueJob>
Sourcefn claim_job_with_options(
&mut self,
queue: &str,
options: QueueClaimOptions,
) -> ThingdResult<Option<QueueJob>>
fn claim_job_with_options( &mut self, queue: &str, options: QueueClaimOptions, ) -> ThingdResult<Option<QueueJob>>
Claim the next ready job from a queue with explicit options.
§Errors
Returns an error when the backing store cannot claim a job.
Sourcefn ack_job(&mut self, queue: &str, id: &str) -> ThingdResult<Option<QueueJob>>
fn ack_job(&mut self, queue: &str, id: &str) -> ThingdResult<Option<QueueJob>>
Acknowledge a leased job as completed.
§Errors
Returns an error when the backing store cannot update the job.
Sourcefn nack_job_with_options(
&mut self,
queue: &str,
id: &str,
options: QueueNackOptions,
) -> ThingdResult<Option<QueueJob>>
fn nack_job_with_options( &mut self, queue: &str, id: &str, options: QueueNackOptions, ) -> ThingdResult<Option<QueueJob>>
Reject a leased job for retry or dead-letter routing with explicit options.
§Errors
Returns an error when the backing store cannot update the job.
Sourcefn list_dead_jobs(&self, queue: &str) -> ThingdResult<Vec<QueueJob>>
fn list_dead_jobs(&self, queue: &str) -> ThingdResult<Vec<QueueJob>>
List dead-letter jobs in a queue.
§Errors
Returns an error when the backing store cannot read dead-letter jobs.
Sourcefn list_queues(&self) -> ThingdResult<Vec<String>>
fn list_queues(&self) -> ThingdResult<Vec<String>>
Sourcefn count_active_jobs(&self) -> ThingdResult<u64>
fn count_active_jobs(&self) -> ThingdResult<u64>
Count total active jobs across all queues.
§Errors
Returns an error when the backing store cannot count active jobs.
Sourcefn count_dead_jobs(&self) -> ThingdResult<u64>
fn count_dead_jobs(&self) -> ThingdResult<u64>
Count total dead-letter jobs across all queues.
§Errors
Returns an error when the backing store cannot count dead jobs.
Provided Methods§
Sourcefn push_jobs_batch(
&mut self,
jobs: Vec<QueueJob>,
) -> ThingdResult<Vec<QueueJob>>
fn push_jobs_batch( &mut self, jobs: Vec<QueueJob>, ) -> ThingdResult<Vec<QueueJob>>
Push multiple jobs onto a queue in a single transaction.
This is significantly faster than calling push_job in a loop.
§Errors
Returns an error when the backing store cannot persist any job.
Sourcefn claim_job(&mut self, queue: &str) -> ThingdResult<Option<QueueJob>>
fn claim_job(&mut self, queue: &str) -> ThingdResult<Option<QueueJob>>
Claim the next ready job from a queue.
§Errors
Returns an error when the backing store cannot claim a job.
Sourcefn claim_and_ack(
&mut self,
queue: &str,
options: QueueClaimOptions,
) -> ThingdResult<Option<QueueJob>>
fn claim_and_ack( &mut self, queue: &str, options: QueueClaimOptions, ) -> ThingdResult<Option<QueueJob>>
Claim and immediately ack a job in a single transaction.
This is faster than calling claim_job + ack_job separately
because it avoids per-operation transaction overhead.
§Errors
Returns an error when the backing store cannot claim or ack the job.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".