Skip to content
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

feat: regularly scheduled jobs (cron) #163

Merged
merged 66 commits into from
Jan 20, 2021
Merged

feat: regularly scheduled jobs (cron) #163

merged 66 commits into from
Jan 20, 2021

Conversation

benjie
Copy link
Member

@benjie benjie commented Dec 20, 2020

Description

Adds cron-like functionality to Graphile Worker, enabling you to schedule jobs on a recurring schedule. Read about it in detail in the included README changes.

This is intended to be used via a crontab file, an example of which is in the README, but you can also do it via the crontab: string library option, or if you need more advanced usage you can use the parsedCrontabItems: ParsedCronItem[] library option; to populate that you'd use parseCrontab(crontab: string) or parseCronItems(items: CronItem[]), for example:

run({
  connectionString: "postgres://localhost/graphile_worker",
  parsedCronItems: parseCronItems([
    {
      task: "send_reminder",
      pattern: "10 10 * * *", // send at 10:10am every day
    },
  ]),
});

Performance impact

If unused, should not impact main worker performance measurably. If used, could probably be more optimal, but it's pretty efficient.

Security impact

No known issues.

@benjie benjie changed the title Cron functionality feat: regularly scheduled jobs (cron) Dec 23, 2020
@Steven4294

This comment has been minimized.

@benjie
Copy link
Member Author

benjie commented Jan 13, 2021

I don't really know how best to attack the remaining tests for this.

@benjie benjie marked this pull request as ready for review January 15, 2021 11:37
ncwp
ncwp previously approved these changes Jan 20, 2021
@ben-pr-p
Copy link
Contributor

Thanks for working a parser into this! I'm sure it will save me at least some time if not a real bug 🥇

@benjie benjie merged commit cb369ad into main Jan 20, 2021
@benjie benjie deleted the cron branch January 20, 2021 13:47
@benjie benjie mentioned this pull request Jan 20, 2021
5 tasks
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.

4 participants