pub struct Core<P> { /* private fields */ }Expand description
The scheduling engine. See the crate docs.
Implementations§
Source§impl<P> Core<P>
impl<P> Core<P>
Sourcepub fn new(cfg: CoreConfig) -> Self
pub fn new(cfg: CoreConfig) -> Self
Create an engine. Structural errors (no pools, duplicate names, min_workers > max_workers) panic; use CoreConfig::validate first to report them gracefully.
Out-of-range numeric settings are clamped to safe values.
Sourcepub fn set_emit_transitions(&mut self, on: bool)
pub fn set_emit_transitions(&mut self, on: bool)
Emit Action::Status for every transition, not only terminal ones.
Sourcepub fn config(&self) -> &CoreConfig
pub fn config(&self) -> &CoreConfig
The (sanitized) configuration the engine runs with.
Sourcepub fn pool_name(&self, pool: PoolId) -> &Arc<str> ⓘ
pub fn pool_name(&self, pool: PoolId) -> &Arc<str> ⓘ
Name of pool. Panics if pool is not from this engine.
Sourcepub fn pool_capacity(&self, pool: PoolId) -> u32
pub fn pool_capacity(&self, pool: PoolId) -> u32
Current worker capacity of pool. Panics if pool is not from this engine.
Sourcepub fn poll_action(&mut self) -> Option<Action<P>>
pub fn poll_action(&mut self) -> Option<Action<P>>
Next action for the driver.
Sourcepub fn drain_actions(&mut self, out: &mut Vec<Action<P>>)
pub fn drain_actions(&mut self, out: &mut Vec<Action<P>>)
Move all pending actions into out.
Sourcepub fn has_actions(&self) -> bool
pub fn has_actions(&self) -> bool
Whether actions are waiting to be polled.
Sourcepub fn next_wakeup(&self) -> Option<Time>
pub fn next_wakeup(&self) -> Option<Time>
Earliest time at which tick has work to do.
Sourcepub fn submit(
&mut self,
now: Time,
spec: TaskSpec<P>,
) -> Result<Submitted, SubmitError>
pub fn submit( &mut self, now: Time, spec: TaskSpec<P>, ) -> Result<Submitted, SubmitError>
Submit one task.
Sourcepub fn try_submit(
&mut self,
now: Time,
spec: TaskSpec<P>,
) -> Result<Submitted, (SubmitError, TaskSpec<P>)>
pub fn try_submit( &mut self, now: Time, spec: TaskSpec<P>, ) -> Result<Submitted, (SubmitError, TaskSpec<P>)>
Like Core::submit, but hands the spec back on rejection (e.g. to retry after
SubmitError::Full).
Sourcepub fn submit_batch(
&mut self,
now: Time,
specs: Vec<TaskSpec<P>>,
) -> Result<Vec<Submitted>, (usize, SubmitError)>
pub fn submit_batch( &mut self, now: Time, specs: Vec<TaskSpec<P>>, ) -> Result<Vec<Submitted>, (usize, SubmitError)>
Submit several tasks atomically. Dependencies may reference keys defined in the batch (in any order). Either all are admitted or none.
Sourcepub fn complete(&mut self, now: Time, lease: LeaseId, outcome: Outcome) -> bool
pub fn complete(&mut self, now: Time, lease: LeaseId, outcome: Outcome) -> bool
Report the outcome of an attempt. Returns false for unknown or stale leases.
Sourcepub fn heartbeat(&mut self, now: Time, lease: LeaseId) -> bool
pub fn heartbeat(&mut self, now: Time, lease: LeaseId) -> bool
Extend a lease (remote workers). Returns false if the lease is unknown.
Sourcepub fn cancel(&mut self, now: Time, target: &TaskRef) -> bool
pub fn cancel(&mut self, now: Time, target: &TaskRef) -> bool
Cancel a task. Running attempts are aborted. Returns false if not live.
Sourcepub fn set_capacity(&mut self, now: Time, pool: PoolId, capacity: u32)
pub fn set_capacity(&mut self, now: Time, pool: PoolId, capacity: u32)
Report the capacity actually available in a pool (its unlabeled workers).
Sourcepub fn set_group_capacity(
&mut self,
now: Time,
pool: PoolId,
labels: &[(Arc<str>, Arc<str>)],
capacity: u32,
)
pub fn set_group_capacity( &mut self, now: Time, pool: PoolId, labels: &[(Arc<str>, Arc<str>)], capacity: u32, )
Report the capacity of the workers of pool that carry exactly labels. Tasks that
require labels run only in groups whose labels include them; tasks without
requirements run in any group, preferring the least specialized. The pool’s capacity is
the sum over its groups.
Sourcepub fn status(&self, target: &TaskRef) -> Option<TaskStatus>
pub fn status(&self, target: &TaskRef) -> Option<TaskStatus>
Current status of a task (live or retained).
Sourcepub fn resolve(&self, target: &TaskRef) -> Option<TaskId>
pub fn resolve(&self, target: &TaskRef) -> Option<TaskId>
Id of a live or retained task by id or key.
Sourcepub fn live_tasks(&self) -> usize
pub fn live_tasks(&self) -> usize
Number of live (non-terminal) tasks.
Sourcepub fn list_tasks<S: AsRef<str>>(
&self,
pools: &[S],
statuses: &[TaskStatus],
after: Option<TaskId>,
limit: usize,
) -> Vec<TaskSummary>
pub fn list_tasks<S: AsRef<str>>( &self, pools: &[S], statuses: &[TaskStatus], after: Option<TaskId>, limit: usize, ) -> Vec<TaskSummary>
Live tasks in id order: those in one of pools (any pool if empty) with one of
statuses (any if empty), with ids above after, at most limit. Unknown pools match
nothing.
Sourcepub fn add_recurring(
&mut self,
now: Time,
spec: RecurringSpec<P>,
) -> Result<(), String>
pub fn add_recurring( &mut self, now: Time, spec: RecurringSpec<P>, ) -> Result<(), String>
Add or replace a recurring (cron) schedule.
Sourcepub fn remove_recurring(&mut self, now: Time, name: &str) -> bool
pub fn remove_recurring(&mut self, now: Time, name: &str) -> bool
Remove a recurring schedule. An occurrence already materialized still runs.
Sourcepub fn recurring_names(&self) -> Vec<Arc<str>>
pub fn recurring_names(&self) -> Vec<Arc<str>>
Names of all recurring schedules.
Sourcepub fn list_recurring(&self) -> Vec<RecurringInfo>
pub fn list_recurring(&self) -> Vec<RecurringInfo>
All recurring schedules, by name.