Crates.io | quartz |
lib.rs | quartz |
version | |
source | src |
created_at | 2024-09-30 10:48:45.235259+00 |
updated_at | 2025-04-01 21:56:34.285761+00 |
description | Port of the original Java Quartz Scheduler to Rust |
homepage | https://github.com/alexsnaps/quartz-rs |
repository | https://github.com/alexsnaps/quartz-rs |
max_upload_size | |
id | 1391581 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Port of the original Quartz Scheduler from Java to Rust.
All very much still work in progress...
v0.0.z
are to be considered experimental towards the first "beta", i.e. v0.1.0
.
To see the roadmap ahead in details, see the milestones on Github
use std::thread;
use std::time::{Duration, SystemTime};
use quartz::{Job, Scheduler, Trigger};
fn main() {
const JOB_ID: &str = "job1";
let sched = Scheduler::new();
// computer a time that is 600 ms from now
let run_time = SystemTime::now() + Duration::from_millis(600);
println!("------- Scheduling Job -------------------");
// define the job and tie it to a closure
let job = Job::with_identity(JOB_ID, "group1", || println!("Hello, world from {JOB_ID}!"));
// Trigger the job to run
let trigger = Trigger::with_identity("trigger1", "group1")
.start_at(run_time)
.repeat(2)
.every(Duration::from_millis(100));
// Tell quartz to schedule the job using our trigger
sched.schedule_job(job, trigger);
println!("{JOB_ID} will run at: {run_time:?}");
// wait long enough so that the scheduler as an opportunity to
// run the job!
println!("------- Waiting 1 second... -------------");
// wait 1 seconds to show job
thread::sleep(Duration::from_secs(1));
// executing...
// shut down the scheduler
println!("------- Shutting Down ---------------------");
sched.shutdown();
}
A Scheduler
runs off a main scheduler thread that will dispatch Job
s for execution to workers
from a thread pool, which is configurable in size. The dispatch occurs based off a Trigger
defining the actual schedule for a Job
to fire.
I worked on the Java version of the Quartz Scheduler in a previous life. I already liked it as a user for its simplicity and enjoyed it even more for the exact same reason when I started extending it at Terracotta. I hope to bring the same joy to Rust developers looking for an easy to use and reliable scheduler.