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

Adding support for enqueue unique by specified key #110

Merged
merged 7 commits into from Sep 12, 2018
Merged

Adding support for enqueue unique by specified key #110

merged 7 commits into from Sep 12, 2018

Conversation

longdavid
Copy link
Contributor

#9

Copy link
Collaborator

@shdunning shdunning left a 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) {
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, I think

Copy link
Collaborator

@shdunning shdunning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work!

@shdunning shdunning merged commit c85b71e into gocraft:master Sep 12, 2018
@Saravanan90
Copy link

@shdunning Wish to see this feature get released, it is just available in master.

@gzhhong
Copy link

gzhhong commented Jan 14, 2021

Hello, can we make a new release for the feature, it is very useful for me

@gzhhong
Copy link

gzhhong commented Jan 14, 2021

@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
Copy link

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

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.

None yet

5 participants