-
Notifications
You must be signed in to change notification settings - Fork 343
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
Adding support for enqueue unique by specified key #110
Conversation
Allow enqueueing unique jobs based on specified key
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.
minor changes
enqueue.go
Outdated
rawJSON, err := job.serialize() | ||
// EnqueueUniqueByKeyIn enqueues a job in the scheduled job queue that is unique on specified key for execution in secondsFromNow seconds. See EnqueueUnique for the semantics of unique jobs. | ||
// Subsequent calls with same key will update arguments | ||
func (e *Enqueuer) EnqueueUniqueByKeyIn(jobName string, secondsFromNow int64, args map[string]interface{}, keyMap map[string]interface{}) (*ScheduledJob, error) { |
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.
🤔 i think EnqueueUniqueInByKey
is a better fit for the name.
enqueue_test.go
Outdated
assert.EqualValues(t, 2, wats) | ||
assert.EqualValues(t, 1, taws) | ||
|
||
// Chewck that arguments got updated to new value |
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.
typo
@@ -348,22 +348,28 @@ return requeuedCount | |||
// KEYS[1] = job queue to push onto | |||
// KEYS[2] = Unique job's key. Test for existence and set if we push. | |||
// ARGV[1] = job | |||
// ARGV[2] = updated job or just a 1 if arguments don't update |
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.
ARGV[2]
is updated job args, right?
end | ||
return 'dup' | ||
` | ||
|
||
// KEYS[1] = scheduled job queue | ||
// KEYS[2] = Unique job's key. Test for existence and set if we push. | ||
// ARGV[1] = job | ||
// ARGV[2] = epoch seconds for job to be run at | ||
// ARGV[2] = updated job or just a 1 if arguments don't update |
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.
same here, I think
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.
nice work!
@shdunning Wish to see this feature get released, it is just available in |
Hello, can we make a new release for the feature, it is very useful for me |
@taylorchu , could you please create a new release 0.5.2 include the latest features in master? thanks |
var redisLuaEnqueueUniqueIn = ` | ||
if redis.call('set', KEYS[2], '1', 'NX', 'EX', '86400') then | ||
redis.call('zadd', KEYS[1], ARGV[2], ARGV[1]) | ||
if redis.call('set', KEYS[2], ARGV[2], 'NX', 'EX', '86400') then |
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.
Why is the TTL not following the secondsFromNow
value, instead being always 24h
#9