feat(schedules): register workflows in five named slots - #6
Merged
Merged
Conversation
Replace per-workflow cron strings with a SLOTS table in schedules/index.ts: hourly at :42, and overnight, morning, afternoon and evening dailies at :17 UTC (11, 17, 23 and 5). A leaf declares slot names and ends in `as const`, so a misspelt slot, a missing `as const` or an empty list fails to compile on the registry line. Target keeps its cron, so the Worker is unchanged. One expression per slot rather than one four-hour daily: Cloudflare hands the Worker the same string for every hour a list expression matches, and a dropped trigger takes one slot down rather than every daily. Only slots with a target become triggers, so wrangler.jsonc carries three until morning or afternoon is claimed. Reassignment: ctan stays hourly; dropbox moves to overnight, three minutes earlier; terraform and tlnet move to evening, about one and two hours later, and now dispatch in the same firing. The three daily expressions are new and pay the propagation delay once.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replaces per-workflow cron strings with a
SLOTStable of five named expressions inschedules/index.ts. A leaf declaresslots: [...]and ends inas const, so a misspelt slot, a leaf withoutas const, or an empty slot list fails to compile on the registry line.Targetkeeps its cron, sosrc/index.tsis untouched.hourlyovernightmorningafternooneveningOne expression per slot rather than one four-hour daily: Cloudflare hands the Worker the same string for every hour a list expression matches, so a target could not pick one, and a dropped trigger takes one slot down rather than every daily. Only slots with a target become triggers;
wrangler.jsonccarries three untilmorningorafternoonis claimed. Registering a workflow in a slot already in use no longer toucheswrangler.jsonc, so it needs notask cronsand has no propagation window.Fire times move
20 11to17 11, three minutes earlier.15 4to17 5, about an hour later.30 3to17 5, about two hours later. It now shares a firing with terraform.The three daily expressions are new strings, so each pays the 15-minute propagation delay once and may miss its first slot after deploy.
Test plan
task checkpasses: typecheck, format, 45 tests, dry-run deployas const, andslots: []each failtscon theREPOSlinetask cronsrun;wrangler.jsonccarries17 11,17 5,42 *task targetsprints the slot columntask instancesshows the17 5 * * *firing with two steps