Skip to main content

WorkloadStore

Struct WorkloadStore 

Source
pub struct WorkloadStore {
    pub workloads: BTreeMap<String, Workload>,
    /* private fields */
}

Fields§

§workloads: BTreeMap<String, Workload>

Implementations§

Source§

impl WorkloadStore

Source

pub fn load(path: impl AsRef<Path>) -> Result<Self, WorkloadError>

Source

pub fn from_db(db: FeltDb) -> Result<Self, WorkloadError>

Source

pub fn refresh(&mut self) -> Result<(), WorkloadError>

Reconcile the projection with the committed store.

The store, not this projection, is authoritative. When its revision has moved since the last reconciliation, every workload row whose document version differs from the projection’s is re-read; rows are borrowed and only changed ones are cloned. Commits by another writer of the store and operations replicated from a peer both become visible here, without a restart.

Source

pub fn fresh(&mut self, id: &str) -> Result<&Workload, WorkloadError>

A workload as committed in the store (see Self::refresh).

Source

pub fn fresh_list( &mut self, tenant: &str, application: &str, ) -> Result<Vec<Workload>, WorkloadError>

An application’s workloads as committed in the store.

Source

pub fn migrate_legacy_file( db: FeltDb, path: &Path, ) -> Result<Self, WorkloadError>

Source

pub fn create( &mut self, input: CreateWorkload, ) -> Result<Workload, WorkloadError>

Source

pub fn admit( &mut self, input: CreateWorkload, ) -> Result<(Workload, bool), WorkloadError>

Create a workload, or return the one this requester already created under the same key.

The key is scoped to the tenant, the application and the requester, so one requester’s key can never return, reveal or block another’s workload. A repeated key is answered with the original workload only when the request is the same — definition, revision, environment, input and capability snapshot; otherwise it is refused with IDEMPOTENCY_KEY_REUSED and nothing is created. The requester’s authorization snapshot is checked before any replay. The boolean is true when this call created the workload.

Source

pub fn get(&self, id: &str) -> Result<&Workload, WorkloadError>

Source

pub fn list(&self, tenant: &str, application: &str) -> Vec<Workload>

Source

pub fn claim( &mut self, id: &str, worker: &str, capabilities: &BTreeSet<String>, now: i64, lease_ms: u64, ) -> Result<WorkloadClaim, WorkloadError>

Source

pub fn start( &mut self, id: &str, claim: &str, worker: &str, token: u64, now: i64, ) -> Result<(), WorkloadError>

Source

pub fn heartbeat( &mut self, id: &str, claim: &str, worker: &str, token: u64, now: i64, extend_ms: u64, ) -> Result<WorkloadClaim, WorkloadError>

Source

pub fn execution_context( &mut self, id: &str, claim: &str, worker: &str, token: u64, now: i64, secret_references: Vec<String>, ) -> Result<WorkloadExecutionContext, WorkloadError>

Source

pub fn checkpoint( &mut self, id: &str, claim: &str, worker: &str, token: u64, state: Value, now: i64, ) -> Result<WorkloadCheckpoint, WorkloadError>

Source

pub fn complete( &mut self, id: &str, claim: &str, worker: &str, token: u64, result_id: &str, output: Value, artifacts: Vec<String>, schema_version: u64, now: i64, ) -> Result<WorkloadResult, WorkloadError>

Source

pub fn fail( &mut self, id: &str, claim: &str, worker: &str, token: u64, kind: &str, error: &str, now: i64, ) -> Result<WorkloadState, WorkloadError>

Source

pub fn fail_with_effect( &mut self, id: &str, claim: &str, worker: &str, token: u64, kind: &str, error: &str, effect: Option<&str>, now: i64, ) -> Result<WorkloadState, WorkloadError>

A worker’s failure report for its current attempt.

Accepted from CLAIMED (the worker could not start) as well as from a started attempt, fenced like every worker call. effect says what the worker knows about external effects: none — it failed before causing any (implied for an attempt that never started); unknown — an effect may have happened. Without it, the policy decides by kind, as before. An unknown effect is decided like a lost worker: retried only when the policy retries worker_failure, whatever kind says. Repeating the same report replays its outcome; any other report from an attempt that already reported gets the fence’s answer (CLAIM_INVALID/STALE_FENCE).

Source

pub fn cancel( &mut self, id: &str, actor: &str, now: i64, ) -> Result<WorkloadState, WorkloadError>

Source

pub fn confirm_cancel( &mut self, id: &str, claim: &str, worker: &str, token: u64, now: i64, ) -> Result<(), WorkloadError>

Source

pub fn timeout( &mut self, id: &str, actor: &str, now: i64, ) -> Result<WorkloadState, WorkloadError>

Source

pub fn retry( &mut self, id: &str, actor: &str, now: i64, ) -> Result<(), WorkloadError>

Source

pub fn retry_with_reason( &mut self, id: &str, actor: &str, now: i64, reason: Option<&str>, ) -> Result<(), WorkloadError>

An operator’s re-arm of failed, dead-lettered or timed-out work.

Each re-arm grants one more attempt, as it always has, and is recorded in the history with its actor and reason. A workload may be re-armed at most retry_policy.max_attempts times, so operator retries cannot become an unbounded loop.

Source

pub fn enforce_deadlines( &mut self, now: i64, ) -> Result<Vec<String>, WorkloadError>

Time out every workload past one of its deadlines (see deadline_breach), as the recovery pass does each second. Deadlines are computed from the workload’s committed timestamps, so the decision is the same after a restart and on any writer of the store.

Source

pub fn recover_expired( &mut self, now: i64, ) -> Result<Vec<String>, WorkloadError>

Trait Implementations§

Source§

impl Clone for WorkloadStore

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V