Skip to main content

TaskClaimStore

Trait TaskClaimStore 

Source
pub trait TaskClaimStore<Task, Kind: 'static, Lane>: Sync {
    type Error: From<TaskCoreError> + Send;

    // Required methods
    fn list_claimable_by_kinds<'life0, 'async_trait>(
        &'life0 self,
        now: DateTime<Utc>,
        stale_before: DateTime<Utc>,
        kinds: &'static [Kind],
        limit: u64,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Task>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn count_active_processing_by_kinds<'life0, 'async_trait>(
        &'life0 self,
        now: DateTime<Utc>,
        kinds: &'static [Kind],
    ) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn claim_candidates_for_lane<'life0, 'life1, 'async_trait>(
        &'life0 self,
        lane_config: TaskLaneConfig<Kind, Lane>,
        candidates: &'life1 [TaskClaimCandidate],
        stale_before: DateTime<Utc>,
        claimed_at: DateTime<Utc>,
        lease_expires_at: DateTime<Utc>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<ClaimedTask>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Product storage adapter required by generic lane claiming.

Implementations keep ownership of database transactions, row locks, product statuses, and ORM models. Forge only provides the shared claim algorithm around capacity checks, token overflow handling, lane validation, and conversion into TaskLease values.

Required Associated Types§

Source

type Error: From<TaskCoreError> + Send

Product error type returned by storage operations.

Required Methods§

Source

fn list_claimable_by_kinds<'life0, 'async_trait>( &'life0 self, now: DateTime<Utc>, stale_before: DateTime<Utc>, kinds: &'static [Kind], limit: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<Task>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Lists due tasks that are claimable for the provided task kinds.

Source

fn count_active_processing_by_kinds<'life0, 'async_trait>( &'life0 self, now: DateTime<Utc>, kinds: &'static [Kind], ) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Counts active processing tasks for the provided kinds.

Source

fn claim_candidates_for_lane<'life0, 'life1, 'async_trait>( &'life0 self, lane_config: TaskLaneConfig<Kind, Lane>, candidates: &'life1 [TaskClaimCandidate], stale_before: DateTime<Utc>, claimed_at: DateTime<Utc>, lease_expires_at: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<Vec<ClaimedTask>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Atomically claims candidate tasks after repeating the capacity check in product storage.

Implementors§