-
Notifications
You must be signed in to change notification settings - Fork 1
Add singleton capabilities #4
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
@vitalinfo Please let me know your thoughts? Notice that test coverage is pending, as well as manual testing. I just want to run the concept (see PR description above) by you guys before proceeding any further. |
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 theory is great. I'm having trouble reading it through right now - it's definitely a big lift, but conceptually seems valid.
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'm not big fan to implement such big changes in the third-party gem
@flusher_lock_ttl = flusher_lock_ttl | ||
end | ||
|
||
def lock_singleton_flusher |
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.
exclamation?
end | ||
|
||
def lock_singleton_flusher | ||
raise "Singleton flusher lock for '#{flusher_key}' already exists" if singleton_flusher_locked? |
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 raise?
class SingletonFlusher < SingletonBase | ||
attr_reader :flusher_lock_ttl | ||
|
||
def initialize(queue, worker_class, flusher_lock_ttl: 5) |
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.
5 seconds?
When the worker passes the
singleton_worker: true
option, flush will not happen if there is a worker of this class/queue already running.The worker is expected to include
Sidekiq::Grouping::SingletonWorkerConcern
and usewith_singleton_worker_lock
to wrap the critical operations it wants to prevent concurrency issues for.By not launching another worker while there is already one running, we achieve 2 goals: