pub struct WorkerPool { /* private fields */ }Expand description
Atomic worker/task coordinator. All clones share one revisioned state lock.
Implementations§
Source§impl WorkerPool
impl WorkerPool
pub fn new() -> Self
pub fn with_limits(limits: DistributedLimits) -> Result<Self, DistributedError>
pub fn snapshot(&self) -> Result<StateSnapshot, DistributedError>
Sourcepub fn task_queue(&self) -> TaskQueue
pub fn task_queue(&self) -> TaskQueue
Return a cloneable task facade guaranteed to share this pool’s state.
Sourcepub fn register_worker(
&self,
expected_revision: u64,
now_secs: u64,
spec: WorkerSpec,
) -> Result<Transition<WorkerNode>, DistributedError>
pub fn register_worker( &self, expected_revision: u64, now_secs: u64, spec: WorkerSpec, ) -> Result<Transition<WorkerNode>, DistributedError>
Register a never-before-seen worker. Duplicate IDs never overwrite.
Sourcepub fn reactivate_worker(
&self,
expected_revision: u64,
now_secs: u64,
expected_generation: u64,
spec: WorkerSpec,
) -> Result<Transition<WorkerNode>, DistributedError>
pub fn reactivate_worker( &self, expected_revision: u64, now_secs: u64, expected_generation: u64, spec: WorkerSpec, ) -> Result<Transition<WorkerNode>, DistributedError>
Reactivate an offline worker under a new generation fence.
Sourcepub fn update_worker(
&self,
expected_revision: u64,
now_secs: u64,
worker_id: &str,
worker_generation: u64,
observation: WorkerObservation,
) -> Result<Transition<WorkerNode>, DistributedError>
pub fn update_worker( &self, expected_revision: u64, now_secs: u64, worker_id: &str, worker_generation: u64, observation: WorkerObservation, ) -> Result<Transition<WorkerNode>, DistributedError>
Update heartbeat, eligibility state, and integer resource observations.
Sourcepub fn get_available_worker(
&self,
now_secs: u64,
) -> Result<Option<WorkerNode>, DistributedError>
pub fn get_available_worker( &self, now_secs: u64, ) -> Result<Option<WorkerNode>, DistributedError>
Return the deterministically selected eligible worker at logical time.
Sourcepub fn assign_task(
&self,
expected_revision: u64,
now_secs: u64,
task_id: &str,
worker_id: &str,
lease_ttl_secs: u64,
) -> Result<Transition<TaskLease>, DistributedError>
pub fn assign_task( &self, expected_revision: u64, now_secs: u64, task_id: &str, worker_id: &str, lease_ttl_secs: u64, ) -> Result<Transition<TaskLease>, DistributedError>
Atomically assign a specific queued task to a specific worker.
Sourcepub fn assign_next(
&self,
expected_revision: u64,
now_secs: u64,
worker_id: &str,
lease_ttl_secs: u64,
) -> Result<Transition<TaskLease>, DistributedError>
pub fn assign_next( &self, expected_revision: u64, now_secs: u64, worker_id: &str, lease_ttl_secs: u64, ) -> Result<Transition<TaskLease>, DistributedError>
Atomically assign the highest-priority FIFO task to a specific worker.
Sourcepub fn assign_next_available(
&self,
expected_revision: u64,
now_secs: u64,
lease_ttl_secs: u64,
) -> Result<Transition<TaskLease>, DistributedError>
pub fn assign_next_available( &self, expected_revision: u64, now_secs: u64, lease_ttl_secs: u64, ) -> Result<Transition<TaskLease>, DistributedError>
Atomically choose both task and worker. Equal worker keys choose the lexicographically smallest worker ID.
Sourcepub fn start_task(
&self,
expected_revision: u64,
now_secs: u64,
lease: &TaskLease,
) -> Result<Transition<StartOutcome>, DistributedError>
pub fn start_task( &self, expected_revision: u64, now_secs: u64, lease: &TaskLease, ) -> Result<Transition<StartOutcome>, DistributedError>
Transition a lease from Leased to Running. Exact replay is a no-op.
Sourcepub fn complete_task(
&self,
expected_revision: u64,
now_secs: u64,
lease: &TaskLease,
) -> Result<Transition<CompletionOutcome>, DistributedError>
pub fn complete_task( &self, expected_revision: u64, now_secs: u64, lease: &TaskLease, ) -> Result<Transition<CompletionOutcome>, DistributedError>
Complete only the current lease. Exact replay returns the same receipt without changing revision or worker counters.
Sourcepub fn cancel_task(
&self,
expected_revision: u64,
now_secs: u64,
ownership: &TaskOwnership,
) -> Result<Transition<CancellationOutcome>, DistributedError>
pub fn cancel_task( &self, expected_revision: u64, now_secs: u64, ownership: &TaskOwnership, ) -> Result<Transition<CancellationOutcome>, DistributedError>
Cancel queued or leased work only with its exact ownership fence. Exact replay is a no-op; a different token fails closed.
Sourcepub fn fail_task(
&self,
expected_revision: u64,
now_secs: u64,
lease: &TaskLease,
) -> Result<Transition<FailureOutcome>, DistributedError>
pub fn fail_task( &self, expected_revision: u64, now_secs: u64, lease: &TaskLease, ) -> Result<Transition<FailureOutcome>, DistributedError>
Fail the current attempt. Retry policy is fixed in DistributedLimits.
Sourcepub fn deregister_worker(
&self,
expected_revision: u64,
now_secs: u64,
worker_id: &str,
worker_generation: u64,
) -> Result<Transition<RecoverySummary>, DistributedError>
pub fn deregister_worker( &self, expected_revision: u64, now_secs: u64, worker_id: &str, worker_generation: u64, ) -> Result<Transition<RecoverySummary>, DistributedError>
Mark a worker offline, fence its generation, and recover every lease it owned in original lease order under the fixed retry policy.
Sourcepub fn recover_expired_leases(
&self,
expected_revision: u64,
now_secs: u64,
) -> Result<Transition<RecoverySummary>, DistributedError>
pub fn recover_expired_leases( &self, expected_revision: u64, now_secs: u64, ) -> Result<Transition<RecoverySummary>, DistributedError>
Recover every lease at or beyond its deadline (now >= expires_at) under
the fixed retry policy.
Sourcepub fn prune_dead_workers(
&self,
expected_revision: u64,
now_secs: u64,
) -> Result<Transition<RecoverySummary>, DistributedError>
pub fn prune_dead_workers( &self, expected_revision: u64, now_secs: u64, ) -> Result<Transition<RecoverySummary>, DistributedError>
Mark heartbeat-stale workers offline and recover their leases. Stale workers are already ineligible for assignment before this command runs.
Sourcepub fn expire_old_tasks(
&self,
expected_revision: u64,
now_secs: u64,
task_ttl_secs: u64,
) -> Result<Transition<usize>, DistributedError>
pub fn expire_old_tasks( &self, expected_revision: u64, now_secs: u64, task_ttl_secs: u64, ) -> Result<Transition<usize>, DistributedError>
Terminally expire every active task whose age reaches task_ttl_secs.
Sourcepub fn get_workers(&self) -> Result<Vec<WorkerNode>, DistributedError>
pub fn get_workers(&self) -> Result<Vec<WorkerNode>, DistributedError>
Return workers in stable worker-ID order.
pub fn get_worker( &self, worker_id: &str, ) -> Result<Option<WorkerNode>, DistributedError>
Sourcepub fn check_invariants(&self) -> Result<(), DistributedError>
pub fn check_invariants(&self) -> Result<(), DistributedError>
Actively verify all cross-record invariants.
Trait Implementations§
Source§impl Clone for WorkerPool
impl Clone for WorkerPool
Source§fn clone(&self) -> WorkerPool
fn clone(&self) -> WorkerPool
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more