#cloudflare-workers #cron #worker #cron-expression #triggers #part #time

no-std saffron

A Quartz-like cron parser used as part of Cron Triggers in Cloudflare Workers

1 unstable release

0.1.0 Feb 1, 2021

#390 in Date and time

Download history 1094/week @ 2023-12-18 679/week @ 2023-12-25 1123/week @ 2024-01-01 1251/week @ 2024-01-08 874/week @ 2024-01-15 1218/week @ 2024-01-22 1381/week @ 2024-01-29 1199/week @ 2024-02-05 1168/week @ 2024-02-12 1051/week @ 2024-02-19 1285/week @ 2024-02-26 1232/week @ 2024-03-04 1355/week @ 2024-03-11 1098/week @ 2024-03-18 1150/week @ 2024-03-25 1800/week @ 2024-04-01

5,624 downloads per month
Used in 12 crates (2 directly)

Custom license

150KB
3.5K SLoC

saffron is a cron parser used as part of the backend for Cron Triggers in Cloudflare Workers. It provides APIs for the complete stack, allowing us to use the same parser everywhere. It's made in two parts:

  1. The parser, which is responsible for reading cron expressions into an easy to understand format, which can be simplified with the compiler, or described with CronExpr::describe.

  2. The compiler, which simplifies expressions into their most compact form. This compact form can check if a chrono date time is contained in a given expression in constant time, no matter the size of the original expression. It can also be used to get future times that match efficiently as an iterator.

The project itself is divided into 4 Rust workspace members:

  1. saffron - the parser itself
  2. saffron-c - the C API used internally by the Workers API
  3. saffron-web - the web API used on the dash in the browser
  4. saffron-worker - the Rust Worker which provides the validate/describe endpoint in the dash API on the edge as a fallback if WASM can't be used in the browser

lib.rs:

A "Quartz scheduler"-like cron parser powering Cron Triggers on Cloudflare Workers.

Dependencies

~2MB
~33K SLoC