docs(research): cron and scheduling landscape #4
Mergedtannerlinsleymerged 2 commits into
main fromrefs/pull/4/headmerged by tannerlinsley - @@ -0,0 +50,21 @@50+51+```ts52+// Hypothetical53+import { createSchedule, runSchedules } from '@tanstack/workflow-cron'54+55+createSchedule({56+ id: 'daily-report',57+ workflow: dailyReport, // a normal workflow definition58+ cron: '0 9 * * MON',59+ input: () => ({ runId: crypto.randomUUID() }),60+ overlapPolicy: 'skip', // skip | buffer | cancel-previous | allow61+})62+63+// Run by a worker process (or DO alarm, or AWS scheduled task)64+await runSchedules({ runStore, scheduleStore })65+```66+67+Two pieces:68+69+**Schedule definitions** — declarative, sit next to workflow definitions.70+**A driver** — polls a schedule store, computes "next fire time," fires `runWorkflow`. Can be deployed as a long-running worker, Durable Object alarm, AWS Lambda + EventBridge, Cloudflare Cron Trigger, etc.
- @@ -0,0 +168,21 @@168+ // Easier: hold the first tick's `step` fn open by making it await169+ // a manually-resolved promise.170+ let releaseFirstStep: (() => void) | null = null171+ workFn.mockImplementationOnce(async () => {172+ invocations++173+ await new Promise<void>((r) => {174+ releaseFirstStep = r175+ })176+ return { summary: 'first' }177+ })178+179+ const tick1 = tickWithSkipOverlap()180+ // Yield so tick1 progresses to inside the step fn and is "running".181+ await vi.advanceTimersByTimeAsync(0)182+183+ // Fire tick2 — same minute window, first is still running.184+ const tick2 = tickWithSkipOverlap()185+ await vi.advanceTimersByTimeAsync(0)186+187+ // Release the first tick.188+ releaseFirstStep!()
tannerlinsley merged this721d546
tannerlinsley closed this
Sign in to join this conversation.
📝 Walkthrough
Walkthrough#
Research documentation is added to the TanStack Workflow repository with a new scheduling and cron landscape analysis. The research directory README is clarified to better characterize design notes, and a new
SCHEDULING.mddocument is cataloged that surveys recurring execution patterns across major workflow engines.Changes#
Workflow Scheduling Research and Documentation
research/README.mdSCHEDULING.mddescribing forward-looking cron and recurring execution research.docs/concepts/scheduling.mdnode-cron), Cloudflare Worker cron, Vercel cron HTTP routes, and AWS EventBridge → Lambda. Describes skip-overlap and buffer-one overlap policies, schedule-store polling guidance, and references the test example.docs/config.jsonconcepts/scheduling.packages/workflow-core/tests/examples.external-cron.test.tspackages/workflow-core/tests/examples.external-cron.test.tspackages/workflow-core/tests/examples.external-cron.test.tssetInterval-based scheduler helper used to drive periodic ticks under fake timers.packages/workflow-core/tests/examples.external-cron.test.tsrunIds and produces expected finished outputs.packages/workflow-core/tests/examples.external-cron.test.tsrunIdchecks to skip starting a second run while a previous run is still in-flight.packages/workflow-core/tests/examples.external-cron.test.tsresearch/SCHEDULING.mdEstimated code review effort#
🎯 2 (Simple) | ⏱️ ~10 minutes
Poem#
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
✨ Finishing Touches
📝 Generate docstrings
Comment `@coderabbitai help` to get the list of available commands and usage tips.