Schedule job in created and active state #285
Replies: 3 comments 10 replies
-
There are a couple of options in the API that you can look into: |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
@timgit would you be interested in a PR for this? |
Beta Was this translation helpful? Give feedback.
-
Hi timgit,
First of all, thank you for this amazing job scheduling tool!
We have a new use case coming up for which we would like to use pg-boss.
We would like to schedule jobs with a kind of
singleton
key, but allow 1 job to be added in the created state when there is already one active. (And discard all the extra ones). At the moment thesingleton
key prevents an extra job to be in the created state due to a DB constraint. If a job is active, no new one will be scheduled.A bit more into why we would need this: some data gets modified on our platform, and as a result a lot of features need to be recalculated.
This recalculation should be done in a background job, as it is too heavy. However, while this job is running with the recalculation, it is still possible that the user modifies the data on out platform again, and a new job would be needed to do the recalculation. That's why we would like to schedule the job in the created state as well.
I looked into the
singleton
key option, but that does not allow scheduling a next job when another one is already active. (In the job itself, we can poll for the latest data, so one in active and one in created is enough. No new jobs need to be scheduled when there is already one in created state.)Do you have any ideas/suggestions on how to tackle this with pg-boss? If not possible with pg-boss, we have a back-up solution without it, but it would be a lot cleaner with pg-boss.
Thank you already,
Roeland
Beta Was this translation helpful? Give feedback.
All reactions