-
Notifications
You must be signed in to change notification settings - Fork 2
adjust unique job comments and add tests #7
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,9 +100,11 @@ func (e *Enqueuer) EnqueueIn(jobName string, secondsFromNow int64, args map[stri | |
|
|
||
| // EnqueueUnique enqueues a job unless a job is already enqueued with the same name and arguments. | ||
| // The already-enqueued job can be in the normal work queue or in the scheduled job queue. | ||
| // Once a worker begins processing a job, another job with the same name and arguments can be enqueued again. | ||
| // Any failed jobs in the retry queue or dead queue don't count against the uniqueness -- so if a job fails and is retried, two unique jobs with the same name and arguments can be enqueued at once. | ||
| // In order to add robustness to the system, jobs are only unique for 24 hours after they're enqueued. This is mostly relevant for scheduled jobs. | ||
| // While a job is enqueued, being processed, or present in the retry queue, the unique lock is held | ||
| // and another job with the same name and arguments cannot be enqueued. The unique key is removed | ||
| // only after the job finishes (or is moved to the dead queue), at which point a new unique job may | ||
| // be enqueued. In order to add robustness to the system, jobs are only unique for 24 hours after | ||
| // they're enqueued — this is mostly relevant for scheduled jobs. | ||
| // EnqueueUnique returns the job if it was enqueued and nil if it wasn't | ||
| func (e *Enqueuer) EnqueueUnique(jobName string, args map[string]interface{}) (*Job, error) { | ||
| return e.EnqueueUniqueByKey(jobName, args, nil) | ||
|
|
@@ -115,9 +117,11 @@ func (e *Enqueuer) EnqueueUniqueIn(jobName string, secondsFromNow int64, args ma | |
|
|
||
| // EnqueueUniqueByKey enqueues a job unless a job is already enqueued with the same name and key, updating arguments. | ||
| // The already-enqueued job can be in the normal work queue or in the scheduled job queue. | ||
| // Once a worker begins processing a job, another job with the same name and key can be enqueued again. | ||
| // Any failed jobs in the retry queue or dead queue don't count against the uniqueness -- so if a job fails and is retried, two unique jobs with the same name and arguments can be enqueued at once. | ||
| // In order to add robustness to the system, jobs are only unique for 24 hours after they're enqueued. This is mostly relevant for scheduled jobs. | ||
| // While a job is enqueued, being processed, or present in the retry queue, the unique lock is held | ||
| // and another job with the same name and key cannot be enqueued. The unique key is removed only after | ||
| // the job finishes (or is moved to the dead queue), at which point a new unique job may be enqueued. | ||
| // In order to add robustness to the system, jobs are only unique for 24 hours after they're enqueued — | ||
| // this is mostly relevant for scheduled jobs. | ||
|
Comment on lines
+120
to
+124
|
||
| // EnqueueUniqueByKey returns the job if it was enqueued and nil if it wasn't | ||
| func (e *Enqueuer) EnqueueUniqueByKey(jobName string, args map[string]interface{}, keyMap map[string]interface{}) (*Job, error) { | ||
| enqueue, job, err := e.uniqueJobHelper(jobName, args, keyMap) | ||
|
|
||
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.
The comment says the unique key is removed only after the job finishes or is moved to the dead queue, but the Redis unique key is also set with a 24h TTL (see redis.go:366) and is not refreshed during processing/retries. That means the lock can expire before completion for long-running or long-delayed jobs. Please clarify the docstring to mention the TTL/possible expiry (or adjust the implementation to refresh the TTL while the job exists).