Skip to content

feat(functions): implement cron scheduling with BullMQ#1507

Open
kkopanidis wants to merge 1 commit into
mainfrom
feat/functions-cron-scheduler
Open

feat(functions): implement cron scheduling with BullMQ#1507
kkopanidis wants to merge 1 commit into
mainfrom
feat/functions-cron-scheduler

Conversation

@kkopanidis

Copy link
Copy Markdown
Contributor

Problem

functionType: 'cron' was accepted by the admin API and UI but never ran on a schedule. The runtime fell through to the event-bus path and subscribed to a channel named after the cron expression, so scheduled functions silently never executed.

Summary

  • Add BullMQ functions-cron-queue with idempotent syncCronJobs() on every refreshRoutes()
  • Stable repeatable job IDs (cron-{functionId}); orphan cleanup on delete/type change
  • Canonical inputs.cronPattern with legacy inputs.event alias; admin validation on upload/patch
  • Cron invocations reuse the VM sandbox, FunctionExecutions, and existing metrics
  • Migration copies legacy inputs.eventinputs.cronPattern for existing cron docs

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other (please describe)

Does this PR introduce a breaking change?

  • Yes
  • No

The PR fulfills these requirements:

  • It's submitted to the main branch

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature

Test plan

  • Create a cron function via Admin API (*/5 * * * *); confirm FunctionExecutions records appear within ~5 minutes
  • Update the cron pattern; confirm cadence changes without duplicate Redis repeatable keys
  • Delete the function; confirm executions stop after refresh
  • Verify functionType: 'event' still subscribes to the bus (no regression)
  • Set functions module active: false; confirm queue drains and ticks stop
  • Rolling deploy with two replicas: single execution per tick

Cron functions now register repeatable BullMQ jobs instead of erroneously
subscribing to the event bus, with pattern validation and execution logging.
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