pub struct WorkloadStore {
pub workloads: BTreeMap<String, Workload>,
/* private fields */
}Fields§
§workloads: BTreeMap<String, Workload>Implementations§
Source§impl WorkloadStore
impl WorkloadStore
pub fn load(path: impl AsRef<Path>) -> Result<Self, WorkloadError>
pub fn from_db(db: FeltDb) -> Result<Self, WorkloadError>
Sourcepub fn refresh(&mut self) -> Result<(), WorkloadError>
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.
Sourcepub fn fresh(&mut self, id: &str) -> Result<&Workload, WorkloadError>
pub fn fresh(&mut self, id: &str) -> Result<&Workload, WorkloadError>
A workload as committed in the store (see Self::refresh).
Sourcepub fn fresh_list(
&mut self,
tenant: &str,
application: &str,
) -> Result<Vec<Workload>, WorkloadError>
pub fn fresh_list( &mut self, tenant: &str, application: &str, ) -> Result<Vec<Workload>, WorkloadError>
An application’s workloads as committed in the store.
pub fn migrate_legacy_file( db: FeltDb, path: &Path, ) -> Result<Self, WorkloadError>
pub fn create( &mut self, input: CreateWorkload, ) -> Result<Workload, WorkloadError>
Sourcepub fn admit(
&mut self,
input: CreateWorkload,
) -> Result<(Workload, bool), WorkloadError>
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.
pub fn get(&self, id: &str) -> Result<&Workload, WorkloadError>
pub fn list(&self, tenant: &str, application: &str) -> Vec<Workload>
pub fn claim( &mut self, id: &str, worker: &str, capabilities: &BTreeSet<String>, now: i64, lease_ms: u64, ) -> Result<WorkloadClaim, WorkloadError>
pub fn start( &mut self, id: &str, claim: &str, worker: &str, token: u64, now: i64, ) -> Result<(), WorkloadError>
pub fn heartbeat( &mut self, id: &str, claim: &str, worker: &str, token: u64, now: i64, extend_ms: u64, ) -> Result<WorkloadClaim, WorkloadError>
pub fn execution_context( &mut self, id: &str, claim: &str, worker: &str, token: u64, now: i64, secret_references: Vec<String>, ) -> Result<WorkloadExecutionContext, WorkloadError>
pub fn checkpoint( &mut self, id: &str, claim: &str, worker: &str, token: u64, state: Value, now: i64, ) -> Result<WorkloadCheckpoint, WorkloadError>
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>
pub fn fail( &mut self, id: &str, claim: &str, worker: &str, token: u64, kind: &str, error: &str, now: i64, ) -> Result<WorkloadState, WorkloadError>
Sourcepub 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>
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).
pub fn cancel( &mut self, id: &str, actor: &str, now: i64, ) -> Result<WorkloadState, WorkloadError>
pub fn confirm_cancel( &mut self, id: &str, claim: &str, worker: &str, token: u64, now: i64, ) -> Result<(), WorkloadError>
pub fn timeout( &mut self, id: &str, actor: &str, now: i64, ) -> Result<WorkloadState, WorkloadError>
pub fn retry( &mut self, id: &str, actor: &str, now: i64, ) -> Result<(), WorkloadError>
Sourcepub fn retry_with_reason(
&mut self,
id: &str,
actor: &str,
now: i64,
reason: Option<&str>,
) -> Result<(), WorkloadError>
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.
Sourcepub fn enforce_deadlines(
&mut self,
now: i64,
) -> Result<Vec<String>, WorkloadError>
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.