-
Notifications
You must be signed in to change notification settings - Fork 1
Compatibility for different Sidekiq uniqueness options #5
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
base: master
Are you sure you want to change the base?
Conversation
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.
Thanks a lot for taking the time to improve this awesome gem, @dirk! I have only a small suggestion which I'd love to hear your thoughts about.
lib/async_cache/workers/sidekiq.rb
Outdated
module Options | ||
def self.included(mod) | ||
if defined?(Sidekiq::Enterprise) | ||
mod.sidekiq_options unique_for: 10.minutes |
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.
These 10.minutes
seem quite arbitrary. Wouldn't it be better to have it living in a config somewhere?
# Only allow one job per set of arguments to ever be in the queue | ||
sidekiq_options :unique => :until_executed | ||
# Pulled out into a module so it can be tested. | ||
module Options |
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.
😍
lib/async_cache/workers/sidekiq.rb
Outdated
module Options | ||
def self.included(mod) | ||
if defined?(Sidekiq::Enterprise) | ||
mod.sidekiq_options unique_for: 10.minutes |
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.
Also, those behaviors seem quite different:
until_executed
if we are using the sidekiq-unique-jobs
gem
VS
for 10 minutes if we are using the sidekiq enterprise gem.
This is one more reason why I believe that this time should live in a config somewhere and be very well documented.
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.
@tiagomjorge these behaviors are more similar than the naming implies. The Sidekiq Enterprise implementation would be equivalent to something like until_executed_or_timeout
. The lock is released whenever the first of these two is satisfied, which is usually execution.
To make these two effectively the same we can set the unique_for
to an arbitrarily long amount of time. 10 minutes might not be long enough for all situations though, so I agree that a documented config would be nice.
@tiagomjorge: Sounds totally reasonable! Any preferences for how that configuration should be defined/provided? |
@dirk we could use an initializer, i.e. |
@tiagomjorge: I'll look into that approach! 😄 |
a wild dirk appears |
...and breaks CI. 😂 |
@tiagomjorge, @taylorlapeyre: CI is all happy now. Mind doing another review? 🙃 (I would assign back to Tiago but I don't got no permissions anymore. 🤣) |
Makes the Sidekiq worker work with both the
sidekiq-unique-jobs
gem and Sidekiq Enterprise.Fixes #4.