Skip to content

Feature: add jenkins-style H token support#46

Open
Zer0AlmostNull wants to merge 1 commit intogawel:masterfrom
Zer0AlmostNull:feature/jenkins-hash-support
Open

Feature: add jenkins-style H token support#46
Zer0AlmostNull wants to merge 1 commit intogawel:masterfrom
Zer0AlmostNull:feature/jenkins-hash-support

Conversation

@Zer0AlmostNull
Copy link

This PR adds support for the H (hash) symbol in the minute and hour fields of cron schedules, following the same approach used by Jenkins.

Motivation
When multiple jobs share the same schedule (for example, "0 * * * *"), they all run at the same time. If those jobs are computationally heavy, this can cause noticeable CPU usage spikes.

The H symbol addresses this by allowing the scheduler to choose a stable, deterministic "random" time for each job, spreading execution more evenly over time without requiring manual offsets.

How it works

  • A hash is calculated based on the function name and the corresponding cron field.
  • Each H token in the schedule is replaced with a deterministic pseudo-random value derived from that hash.

Additional notes

  • Unit tests were generated with the help of Microsoft Copilot

I'm open to feedback and suggestions on the implementation details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant