pub struct ScheduledTaskGroup { /* private fields */ }Expand description
Represents scheduled task group.
Implementations§
Source§impl ScheduledTaskGroup
impl ScheduledTaskGroup
Sourcepub fn schedule<F, Fut>(
&self,
config: ScheduledTaskConfig,
policy: ScheduledExecutionPolicy,
task: F,
) -> RuntimeResult<ScheduledTaskRegistrationOutcome>
pub fn schedule<F, Fut>( &self, config: ScheduledTaskConfig, policy: ScheduledExecutionPolicy, task: F, ) -> RuntimeResult<ScheduledTaskRegistrationOutcome>
Schedules task with the cadence of config and the run limits of policy.
The driver and runs belong to this group and stop when it is cancelled.
A fixed-delay schedule runs task on its driver; a fixed-rate schedule
starts each run as its own task once a run slot is free. A duplicate
name leaves the existing registration unchanged.
§Errors
Returns an unsupported error when the period is zero or policy
contradicts the mode of config: fixed-delay and non-overlapping
schedules need a serial policy, an overlapping schedule needs a bounded
one. Returns an operational error when the driver cannot be spawned.
Sourcepub fn schedule_operation<F, Fut>(
&self,
operation: &OperationContext,
config: ScheduledTaskConfig,
policy: ScheduledExecutionPolicy,
task: F,
) -> RuntimeResult<ScheduledTaskRegistrationOutcome>
pub fn schedule_operation<F, Fut>( &self, operation: &OperationContext, config: ScheduledTaskConfig, policy: ScheduledExecutionPolicy, task: F, ) -> RuntimeResult<ScheduledTaskRegistrationOutcome>
Schedules task like Self::schedule as part of a bounded operation.
The driver and runs are registered with this group’s fixed component owner and stop when the operation is cancelled or reaches its deadline.
§Errors
Returns the same errors as Self::schedule.
Sourcepub fn schedule_controlled<F, Fut>(
&self,
config: ScheduledTaskConfig,
task: F,
) -> RuntimeResult<ScheduledTaskRegistrationOutcome>where
F: FnMut() -> Fut + Send + 'static,
Fut: Future<Output = ScheduledTaskControl> + Send + 'static,
pub fn schedule_controlled<F, Fut>(
&self,
config: ScheduledTaskConfig,
task: F,
) -> RuntimeResult<ScheduledTaskRegistrationOutcome>where
F: FnMut() -> Fut + Send + 'static,
Fut: Future<Output = ScheduledTaskControl> + Send + 'static,
Schedules fixed-delay work that can end its own schedule.
The schedule stops after a run returns ScheduledTaskControl::Stop.
§Errors
Returns an unsupported error when the period is zero or config is not
a fixed-delay schedule, and an operational error when the driver cannot
be spawned.
Sourcepub fn snapshot(&self) -> Vec<ScheduledTaskSnapshot>
pub fn snapshot(&self) -> Vec<ScheduledTaskSnapshot>
Returns the snapshot.
Sourcepub fn observer(&self, names: &[&str]) -> ScheduledTaskObserver
pub fn observer(&self, names: &[&str]) -> ScheduledTaskObserver
Observes a fixed selection of schedule names without keeping tasks alive.
Duplicate names are removed. Callers should select component-level jobs, not names derived from requests or resources.
Sourcepub fn clear_completed(&self) -> RuntimeResult<()>
pub fn clear_completed(&self) -> RuntimeResult<()>
Clears completed schedule registrations so a fixed component owner can start a new operation generation with the same schedule names.
§Errors
Returns an error while the component group still has active tasks.
Sourcepub async fn shutdown(&self, timeout: Duration) -> ShutdownReport
pub async fn shutdown(&self, timeout: Duration) -> ShutdownReport
Shuts down the owned service.
Sourcepub async fn shutdown_until(&self, deadline: ShutdownDeadline) -> ShutdownReport
pub async fn shutdown_until(&self, deadline: ShutdownDeadline) -> ShutdownReport
Shuts down the owned service using one absolute deadline.