this post was submitted on 18 Sep 2023
7 points (73.3% liked)

Rust Programming

8159 readers
2 users here now

founded 5 years ago
MODERATORS
 

Is there any library for the queueing mechanism?

What's used by the most - Cron? But a task or rather script executed by Cron won't access to the context of an application. Meaning, a task will have be an independent unit. Whereas I want is a library to use inside a project such that it'll have access to everything.

Anything similar to Sidekiq exist in Rust?

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 6 points 1 year ago* (last edited 1 year ago) (4 children)
let mut scheduler = Scheduler::with_tz(chrono::Utc);

scheduler.every(10.minutes()).plus(30.seconds()).run(|| println!("Periodic task"));

scheduler.every(1.day()).at("3:20 pm").run(|| println!("Daily task")); 

scheduler.every(Tuesday).at("14:20:17").and_every(Thursday).at("15:00").run(|| println!("Biweekly task")); 

Damn, that a really ingenious and intuitive use of the builder pattern.

Kudos to the devs!

[–] [email protected] 0 points 1 year ago (3 children)

Scheduler

what library is it from?

[–] [email protected] 1 points 1 year ago (2 children)
[–] [email protected] 0 points 1 year ago (1 children)

@SuddenlyBlowGreen @nothingness I recently needed that, but fuzzy. Like I want a task ran anywhere between 1PM and 2PM. Can this be accomplished with the clockwerk crate?

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago)

You could schedule a task at 1 PM, then generate a random number between 0-60 inside that task, wait that many minutes, then launch the actual task.