pub struct TaskScheduler { /* private fields */ }
Expand description
Main task scheduler
Implementations§
Source§impl TaskScheduler
impl TaskScheduler
Sourcepub fn new(config: SchedulerConfig) -> Self
pub fn new(config: SchedulerConfig) -> Self
Create a new task scheduler
Sourcepub async fn start(&self) -> SchedulerResult<()>
pub async fn start(&self) -> SchedulerResult<()>
Start the scheduler
Sourcepub async fn stop(&self) -> SchedulerResult<()>
pub async fn stop(&self) -> SchedulerResult<()>
Stop the scheduler
Sourcepub async fn schedule_job(
&self,
task: Arc<Task>,
trigger: Arc<dyn Trigger>,
) -> SchedulerResult<String>
pub async fn schedule_job( &self, task: Arc<Task>, trigger: Arc<dyn Trigger>, ) -> SchedulerResult<String>
Schedule a new job
Sourcepub async fn schedule_job_with_id(
&self,
job_id: impl Into<String>,
task: Arc<Task>,
trigger: Arc<dyn Trigger>,
) -> SchedulerResult<String>
pub async fn schedule_job_with_id( &self, job_id: impl Into<String>, task: Arc<Task>, trigger: Arc<dyn Trigger>, ) -> SchedulerResult<String>
Schedule a job with a specific ID
Sourcepub async fn unschedule_job(&self, job_id: &str) -> SchedulerResult<()>
pub async fn unschedule_job(&self, job_id: &str) -> SchedulerResult<()>
Unschedule a job
Sourcepub async fn set_job_enabled(
&self,
job_id: &str,
enabled: bool,
) -> SchedulerResult<()>
pub async fn set_job_enabled( &self, job_id: &str, enabled: bool, ) -> SchedulerResult<()>
Enable or disable a job
Sourcepub async fn get_job(&self, job_id: &str) -> Option<ScheduledJob>
pub async fn get_job(&self, job_id: &str) -> Option<ScheduledJob>
Get job information
Sourcepub async fn get_all_jobs(&self) -> Vec<ScheduledJob>
pub async fn get_all_jobs(&self) -> Vec<ScheduledJob>
Get all jobs
Sourcepub async fn get_jobs_by_group(&self, group: &str) -> Vec<ScheduledJob>
pub async fn get_jobs_by_group(&self, group: &str) -> Vec<ScheduledJob>
Get jobs by task group
Sourcepub async fn execute_job_now(&self, job_id: &str) -> SchedulerResult<String>
pub async fn execute_job_now(&self, job_id: &str) -> SchedulerResult<String>
Execute a job immediately (ad-hoc execution)
Sourcepub async fn schedule_delayed_job(
&self,
task: Arc<Task>,
delay: Duration,
) -> SchedulerResult<String>
pub async fn schedule_delayed_job( &self, task: Arc<Task>, delay: Duration, ) -> SchedulerResult<String>
Schedule a delayed job (execute once after delay)
Sourcepub async fn schedule_delayed_job_with_id(
&self,
job_id: impl Into<String>,
task: Arc<Task>,
delay: Duration,
) -> SchedulerResult<String>
pub async fn schedule_delayed_job_with_id( &self, job_id: impl Into<String>, task: Arc<Task>, delay: Duration, ) -> SchedulerResult<String>
Schedule a delayed job with specific ID
Sourcepub async fn schedule_interval_job_with_delay(
&self,
task: Arc<Task>,
interval: Duration,
initial_delay: Duration,
) -> SchedulerResult<String>
pub async fn schedule_interval_job_with_delay( &self, task: Arc<Task>, interval: Duration, initial_delay: Duration, ) -> SchedulerResult<String>
Schedule an interval job with initial delay
Sourcepub async fn schedule_interval_job_with_delay_and_id(
&self,
job_id: impl Into<String>,
task: Arc<Task>,
interval: Duration,
initial_delay: Duration,
) -> SchedulerResult<String>
pub async fn schedule_interval_job_with_delay_and_id( &self, job_id: impl Into<String>, task: Arc<Task>, interval: Duration, initial_delay: Duration, ) -> SchedulerResult<String>
Schedule an interval job with initial delay and specific ID
Sourcepub async fn execute_job_now_with_delay(
&self,
job_id: &str,
execution_delay: Option<Duration>,
) -> SchedulerResult<String>
pub async fn execute_job_now_with_delay( &self, job_id: &str, execution_delay: Option<Duration>, ) -> SchedulerResult<String>
Execute a job immediately with optional execution delay
Sourcepub async fn get_execution(&self, execution_id: &str) -> Option<TaskExecution>
pub async fn get_execution(&self, execution_id: &str) -> Option<TaskExecution>
Get task execution
Sourcepub async fn cancel_execution(&self, execution_id: &str) -> SchedulerResult<()>
pub async fn cancel_execution(&self, execution_id: &str) -> SchedulerResult<()>
Cancel a running task execution
Sourcepub async fn get_status(&self) -> SchedulerStatus
pub async fn get_status(&self) -> SchedulerStatus
Get scheduler status
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TaskScheduler
impl !RefUnwindSafe for TaskScheduler
impl Send for TaskScheduler
impl Sync for TaskScheduler
impl Unpin for TaskScheduler
impl !UnwindSafe for TaskScheduler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more