Skip to main content

Crate tasklet

Crate tasklet 

Source
Expand description

An asynchronous task scheduling library written in Rust.

tasklet allows you to create scheduled tasks with specific execution patterns and run them asynchronously using Tokio. It supports cron-like scheduling expressions and provides a builder pattern for easy task creation.

§Highlights

§Example

use tasklet::task::TaskStepStatusOk::Success;
use tasklet::{TaskBuilder, TaskScheduler};

#[tokio::main]
async fn main() {
    let mut scheduler = TaskScheduler::default(chrono::Local);
    let _ = scheduler.add_task(
        TaskBuilder::new(chrono::Local)
            .every("1 * * * * * *")
            .description("A simple task")
            .add_step("Step 1", || async { Ok(Success) })
            .build(),
    );
    scheduler.run().await;
}

Re-exports§

pub use errors::TaskError;
pub use errors::TaskResult;
pub use retry::Backoff;
pub use retry::RetryPolicy;
pub use task::Task;

Modules§

errors
Error types for the tasklet library.
retry
Retry policies for task steps.
task

Macros§

scheduler_log
Macro for consistent scheduler logging
step_log
Macro for consistent task step logging
task_log
Macro for consistent task-related logging

Structs§

SchedulerHandle
A cloneable handle used to control a running TaskScheduler.
TaskBuilder
Task builder function.
TaskGenerator
Task generation structure.
TaskScheduler
Task scheduler and executor.