Skip to main content

RuntimeRepository

Trait RuntimeRepository 

Source
pub trait RuntimeRepository: Send + Sync {
    // Required methods
    fn list_dispatchable_attempts(
        &self,
        now: DateTime<Utc>,
        limit: usize,
    ) -> Result<Vec<AttemptDispatchRecord>, KernelError>;
    fn upsert_lease(
        &self,
        attempt_id: &str,
        worker_id: &str,
        lease_expires_at: DateTime<Utc>,
    ) -> Result<LeaseRecord, KernelError>;
    fn heartbeat_lease(
        &self,
        lease_id: &str,
        heartbeat_at: DateTime<Utc>,
        lease_expires_at: DateTime<Utc>,
    ) -> Result<(), KernelError>;
    fn expire_leases_and_requeue(
        &self,
        stale_before: DateTime<Utc>,
    ) -> Result<u64, KernelError>;
    fn latest_seq_for_run(&self, run_id: &RunId) -> Result<Seq, KernelError>;

    // Provided method
    fn transition_timed_out_attempts(
        &self,
        _now: DateTime<Utc>,
    ) -> Result<u64, KernelError> { ... }
}
Expand description

Runtime repository contract used by scheduler and lease manager.

Implementations are responsible for making dispatch ownership transitions explicit:

  • list_dispatchable_attempts must preserve the repository’s dispatch order.
  • upsert_lease must atomically claim only dispatchable attempts and move the attempt into leased ownership when the claim succeeds.
  • expire_leases_and_requeue must reclaim only leases whose expiry is older than the supplied stale cutoff, so callers can apply a heartbeat grace window before requeueing work.

Required Methods§

Source

fn list_dispatchable_attempts( &self, now: DateTime<Utc>, limit: usize, ) -> Result<Vec<AttemptDispatchRecord>, KernelError>

Return attempts eligible for dispatch at the current time.

Source

fn upsert_lease( &self, attempt_id: &str, worker_id: &str, lease_expires_at: DateTime<Utc>, ) -> Result<LeaseRecord, KernelError>

Create or replace a lease for an attempt.

Source

fn heartbeat_lease( &self, lease_id: &str, heartbeat_at: DateTime<Utc>, lease_expires_at: DateTime<Utc>, ) -> Result<(), KernelError>

Refresh heartbeat for an existing lease.

Source

fn expire_leases_and_requeue( &self, stale_before: DateTime<Utc>, ) -> Result<u64, KernelError>

Expire stale leases and requeue affected attempts.

Source

fn latest_seq_for_run(&self, run_id: &RunId) -> Result<Seq, KernelError>

Returns latest persisted sequence for a run (used by replay wiring).

Provided Methods§

Source

fn transition_timed_out_attempts( &self, _now: DateTime<Utc>, ) -> Result<u64, KernelError>

Transition attempts that exceeded their configured execution timeout.

Implementors§