Skip to content

Declarative schedules #1226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Jul 18, 2024
Merged

Declarative schedules #1226

merged 26 commits into from
Jul 18, 2024

Conversation

matt-aitken
Copy link
Member

This is for this roadmap feature: https://feedback.trigger.dev/p/static-cron-attached-to-tasks

We've called them "declarative" schedules as they're declared in your code on a task like this:

export const firstScheduledTask = schedules.task({
  id: "first-scheduled-task",
  //every two hours (UTC timezone)
  cron: "0 */2 * * *",
  run: async (payload, { ctx }) => {
    //do something
  },
});

Or you can specify a timezone if you don't want UTC:

export const secondScheduledTask = schedules.task({
  id: "second-scheduled-task",
  cron: {
    //5am every day Tokyo time
    pattern: "0 5 * * *",
    timezone: "Asia/Tokyo",
  },
  run: async (payload) => {},
});

These schedules are synced when you run the dev or deploy CLI commands. If you create, edit or delete the cron property it will be reflected when this sync happens.

You can't delete, disable or enable them using the other SDK functions that work with imperative schedules.

Copy link

changeset-bot bot commented Jul 18, 2024

🦋 Changeset detected

Latest commit: d74099e

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@matt-aitken matt-aitken merged commit 8ba9987 into main Jul 18, 2024
2 checks passed
@matt-aitken matt-aitken deleted the features/static-schedules branch July 18, 2024 19:24
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.

2 participants