-
Notifications
You must be signed in to change notification settings - Fork 390
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(queue): add new upsertJobScheduler method #2797
Conversation
e288570
to
e5bac49
Compare
e5bac49
to
e1516ff
Compare
src/commands/removeJob-2.lua
Outdated
-- This will require a recursive check before the removal processs could start. | ||
-- We could expand isLocked for that. | ||
if rcall("ZSCORE", prefix .. "delayed", jobId) and rcall("HGET", jobKey, "rjk") then | ||
return -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about returning same error code as JobBelongsToJobScheduler that is -8
} | ||
|
||
async upsertJobScheduler<T = any, R = any, N extends string = string>( | ||
jobSchedulerId: string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a current logic to add a repeatable job without an specific key, this value is generated base on the repeat options. We could preserve that functionality by generating jobSchedulerId if it's not specified
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I want to avoid actually. With this API the key is mandatory, and when the old API gets deprecated it will be mandatory. Forcing the user to specify a key eliminates most of the pain we had with the old API and also makes the code much simpler and robust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, let's do it
…using drain and clean
…using drain and clean
Hey @manast |
@SrdjanCosicPrica If you remove the delayed jobs that belongs to a job scheduler then they will stop repeating. You should remove the job scheduler instead if you need to get rid of the repetitions. We do not consider it a breaking change as this was not supposed to happen. |
Ok I can understand that. |
This PR introduces a couple of new methods as well as new terminology for our "Repeatable Jobs".
Before this PR we had the confusing notion of "repeatable job", where there was also a "meta repeatable job" that stores the actual information on how often a job should be repeated.
With this PR however we aim to make it clearer and easier to use. We introduce the concept of a Job Scheduler, which is nothing else than a job factory for repeatable jobs. The Job Scheduler exists in Redis in the same key and format as the old meta repeatable job, we are just changing the terminology and introducing new methods that simplify its usage while deprecating the older ones.
The new method is called
upsertJobScheduler
. Which as the name implies either inserts a new scheduler or updates an existing one. Job Schedulers are all referred via their IDs. So you must choose a unique ID for every scheduler. This simplifies the process of updating and deleting them in the future, as well as to map jobs to their respective job schedulers.This is the complete signature of the new method: