Open Hexagon opened 10 months ago
From version 2.0.0
, croner
uses minute granularity by default, but can optionally enable seconds or require them by using the builder methods .with_seconds_optional()
and .with_seconds_required()
. Therefore, technically, second granularity could be an option for Deno.cron()
.
This would be helpful for our use-case of tracking the connection status of our sensor network - we currently use setInterval
to go through every 15 seconds and mark sensors that we haven't received a packet from recently as offline.
However setInterval
has it's own problems, one of which is clarity on how often it runs. Supporting seconds in Deno.cron
would help with this.
There is also a good example of cron syntax that supports seconds here - just type in 6 *
s.
Deno.cron
uses thesaffron
crate for parsing cron patterns, which doesn't support seconds. I propose to include seconds in the cron pattern syntax. While not commonly available in "system cron", seconds is vital when dealing with in-application scheduling whichDeno.cron
is used for.A list of possible use cases for second granularity scheduling with
Deno.cron
:Example:
Possible Solution:
I suggest checking out my drop in replacement for
saffron
calledcroner
. This extends the existing cron pattern syntax to include seconds. It's designed to set seconds to 0 by default if omitted in a 5-part pattern, ensuring backward compatibility. It also include other improvements such as time-zone support and POSIX compatible cron syntax.