-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
How do I ensure that a the same job can't run twice? (unique job / avoid duplicates) #531
Comments
Exactly. GoodJob's ActiveJob Concurrency extension can provide equivalent functionality to sidekiq-unique-jobs This would be the equivalent of class MyJob < ApplicationJob
include GoodJob::ActiveJobExtensions::Concurrency
good_job_control_concurrency_with(total_limit: 1)
# ....
end |
Just to confirm:
Is that right? |
Concurrency is limited based on whatever the |
Ah. ok, so then this should work and allow multiples of the same job, as long as arguments are different? (whatever the arguments are):
|
That exact code won't execute because # an example scalpel based on your specific method signature
good_job_control_concurrency_with(total_limit: 1, key: -> { arguments[0] })
# or with a hammer
good_job_control_concurrency_with(total_limit: 1, key: -> { arguments.to_json }) |
Why is .to_json necessary? - can I specify just arguments in the lambda? |
You'll get whatever |
Ah, understood, thank you! |
I am looking for something like this for good_job: https://github.com/mhenrixon/sidekiq-unique-jobs
To be able to do specifically the equivalent of this:
Is this the equivalent with good_job? <
Or am I misunderstanding?
The text was updated successfully, but these errors were encountered: