Async Rust cron scheduler running on Tokio.

Overview

Grizzly Cron Scheduler

A simple and easy to use scheduler, built on top of Tokio, that allows you to schedule async tasks using cron expressions (with optional random fuzzy offsets for each trigger).

Tasks can be of two types:

  • Parallel: Two instances of this job can run at the same time if the previous run has not completed and new trigger time has arrived.
  • Sequential: The next run of the job will not start until the previous run has completed, so some triggers might be skipped.

Alternatives

  • tokio cron scheduler: Well-maintained and feature-rich, but it does not support fuzzy scheduling or differentiate between parallel and sequential jobs.

Features

  • Schedule parallel and sequential jobs
  • Schedule jobs using cron expressions
  • Integrated with Tracing for logging
  • Add random fuzzy offset to each trigger time
    • for example, if the job is configured to run at 30th second of every minute, you can add a fuzzy offset of 5 seconds, so the job will run at a random point between 25th and 35th second of every minute

Example

use std::sync::Arc;
use grizzly_scheduler::scheduler::Scheduler;

let scheduler = grizzly_scheduler::scheduler::Scheduler::new_in_utc();
let important_shared_state = Arc::new(5);
let cloned_state = important_shared_state.clone();

let job_id = scheduler.schedule_parallel_job(
       "*/5 * * * * *",                          // run the job on every second divisible by 5 of every minute
       Some("Example Parallel Job".to_string()), // this name will appear in the tracing logs
       Some(chrono::Duration::seconds(2)),       // we want the fuzzy effect of maximally +/-2 seconds
       move ||
          {
             let cloned_state = cloned_state.clone();
             async move {
                 tracing::info!("We are using our important shared state! {}", cloned_state);
             }
          },
       ).unwrap();
scheduler.start().unwrap();

License

This project is licensed under MIT license, which can be found in the LICENSE file.

Contribution

All contributions are welcome! Please feel free to open an issue or a pull request.

You might also like...
Mommy's here to support you when running cargo~

cargo-mommy Mommy's here to support you when running cargo~ ❤️ Installation Install cargo-mommy like you would any other cargo extension~ cargo inst

Golang like WaitGroup implementation for sync/async Rust.

wg Golang like WaitGroup implementation for sync/async Rust.

single file, std only, async Rust executor

whorl - A single file, std only, async Rust executor whorl was created to teach you how async executors work in Rust. It is not the fastest executor n

BPF library for Async Rust, complementary for libbpf-rs.

libbpf-async A library for writing BPF programs in Async Rust, complementary for libbpf-rs, Rust wrapper for libbpf. Currently, this provides Async-fr

Rust library for one-time async initialization

async-lazy An async version of once_cell::sync::Lazy, std::sync::OnceLock or lazy_static. Uses tokio's sychronization primitives. This crate offers an

Async executor for WebAssembly

There are a number of async task executors available in Rust's ecosystem. However, most (if not all?) of them rely on primitives that might not be available or optimal for WebAssembly deployment at the time.

The feature-rich, portable async channel library

The feature-rich, portable async channel library crates.io docs.rs Why use Postage? Includes a rich set of channels. | barrier | broadcast | dispa

Another Async IO Framework based on io_uring

kbio, the Async IO Framework based on io_uring, is used in KuiBaDB to implement async io. Features Support multi-threading concurrent task submission.

async-alloc-counter measures max allocations in a future invocation

async-alloc-counter measures max allocations in a future invocation see examples/ for usage This allocator can be used as follows: use async_alloc_cou

Owner
Ivan Brko
Software Engineer
Ivan Brko
Mix async code with CPU-heavy thread pools using Tokio + Rayon

tokio-rayon Mix async code with CPU-heavy thread pools using Tokio + Rayon Resources Documentation crates.io TL;DR Sometimes, you're doing async stuff

Andy Barron 74 Jan 2, 2023
Pure Rust library for Apache ZooKeeper built on tokio

zookeeper-async Async Zookeeper client written 100% in Rust, based on tokio. This library is intended to be equivalent with the official (low-level) Z

Kamil Rojewski 16 Dec 16, 2022
Provides utility functions to perform a graceful shutdown on an tokio-rs based service

tokio-graceful-shutdown IMPORTANT: This crate is in an early stage and not ready for production. This crate provides utility functions to perform a gr

null 61 Jan 8, 2023
An asynchronous IO utilities crate powered by tokio.

An asynchronous IO utilities crate powered by tokio.

Harry 2 Aug 18, 2022
dark-std an Implementation of asynchronous containers build on tokio

dark-std dark-std is an Implementation of asynchronous containers build on tokio. It uses a read-write separation design borrowed from Golang SyncHash

darkrpc 4 Dec 13, 2022
Thin wrapper around [`tokio::process`] to make it streamable

This library provide ProcessExt to create your own custom process

null 4 Jun 25, 2022
Rc version `tokio-rs/bytes`

RcBytes The aim for this crate is to implement a Rc version bytes, which means that the structs in this crate does not implement the Sync and Send. Th

Al Liu 2 Aug 1, 2022
Alternative StreamMap fork of tokio-stream

streammap-ext This is a fork of StreamMap from tokio-stream crate. The only difference between the implementations is that this version of StreamMap n

MetalBear 5 Aug 18, 2022
Open-source Rewind.ai clone written in Rust and Vue running 100% locally with whisper.cpp

mind-overflow Open-source Rewind.AI clone built with Tauri and Vue. Leverages whisper.cpp for Speech-to-Text and (wip: llama.cpp for Text generation a

Maxime Dolores 4 Aug 9, 2023
Detect if code is running inside a virtual machine (x86 and x86-64 only).

inside-vm Detect if code is running inside a virtual machine. Only works on x86 and x86-64. How does it work Measure average cpu cycles when calling c

null 34 Oct 3, 2022