pub trait WorkState: Send + Sync {
// Required methods
fn claim_strength(&self) -> ClaimStrength;
fn pull_ready<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<WorkTicket>, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn active_claims<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ActiveClaim>, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn claim<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ticket: &'life1 TicketRef,
owner: &'life2 OwnerId,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<ClaimResult, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn renew<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ticket: &'life1 TicketRef,
owner: &'life2 OwnerId,
) -> Pin<Box<dyn Future<Output = Result<ClaimResult, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn release<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ticket: &'life1 TicketRef,
owner: &'life2 OwnerId,
disposition: Disposition,
) -> Pin<Box<dyn Future<Output = Result<(), SourceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn push_outcome<'life0, 'life1, 'async_trait>(
&'life0 self,
outcome: &'life1 WorkOutcome,
) -> Pin<Box<dyn Future<Output = Result<(), SourceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
The daemon-facing contract for reading and claiming work.
Implementations must uphold these invariants:
- Attempts increment only inside
WorkState::claim, never on release. - A claim is committed at the source before any run is recorded against it.
- An outcome is durably recorded before
WorkState::releaseorWorkState::push_outcomeis called.
Required Methods§
Sourcefn claim_strength(&self) -> ClaimStrength
fn claim_strength(&self) -> ClaimStrength
What this source can promise about claims. The dispatcher never
branches on this; it exists for status display and for refusing
multi-writer setups on LocalOnly sources.
Sourcefn pull_ready<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<WorkTicket>, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn pull_ready<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<WorkTicket>, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Refresh the daemon’s read cache. Selection runs on the cache; pull is periodic, never per-tick.
Sourcefn active_claims<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ActiveClaim>, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn active_claims<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ActiveClaim>, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Claims visible at the source. Recovery compares these with recorded runs and releases a claim whose second admission commit never landed.
Sourcefn claim<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ticket: &'life1 TicketRef,
owner: &'life2 OwnerId,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<ClaimResult, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn claim<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ticket: &'life1 TicketRef,
owner: &'life2 OwnerId,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<ClaimResult, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
The only authoritative check. Succeeds iff the ticket is still ready at the source. Lost is a normal, silent outcome.
Sourcefn renew<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ticket: &'life1 TicketRef,
owner: &'life2 OwnerId,
) -> Pin<Box<dyn Future<Output = Result<ClaimResult, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn renew<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ticket: &'life1 TicketRef,
owner: &'life2 OwnerId,
) -> Pin<Box<dyn Future<Output = Result<ClaimResult, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Heartbeat for long runs. An expired claim is reclaimable by peers.
Sourcefn release<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ticket: &'life1 TicketRef,
owner: &'life2 OwnerId,
disposition: Disposition,
) -> Pin<Box<dyn Future<Output = Result<(), SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn release<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ticket: &'life1 TicketRef,
owner: &'life2 OwnerId,
disposition: Disposition,
) -> Pin<Box<dyn Future<Output = Result<(), SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Give the ticket back, per policy. Repeating a completed release is an idempotent success; it never consumes another attempt.
Sourcefn push_outcome<'life0, 'life1, 'async_trait>(
&'life0 self,
outcome: &'life1 WorkOutcome,
) -> Pin<Box<dyn Future<Output = Result<(), SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn push_outcome<'life0, 'life1, 'async_trait>(
&'life0 self,
outcome: &'life1 WorkOutcome,
) -> Pin<Box<dyn Future<Output = Result<(), SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Terminal push. Fire-and-forget from the dispatcher’s view.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl WorkState for LocalSqlite
SQLite satisfies atomic claims with an IMMEDIATE transaction and a conditional ticket update. The ticket row is authoritative for attempts: claim consumes one attempt, while release preserves that count as evidence of the completed try. This backend never records runs, and its local-source outcome push is idempotent because release already applied the durable ticket state.