-
Notifications
You must be signed in to change notification settings - Fork 78
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
Add dynamic cooldown policies #174
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #174 +/- ##
=======================================
Coverage 98.69% 98.69%
=======================================
Files 19 19
Lines 460 461 +1
Branches 77 77
=======================================
+ Hits 454 455 +1
Misses 6 6 ☔ View full report in Codecov by Sentry. |
I'm not sure about the |
My rationale behind unit of work was that one may want to have different period/threshold based on job class and/or args. I guess the most straight-forward API in this case will be: c.cooldown_period = lambda do |queue_name, message|
job_record = Sidekiq::JobRecord.new(message)
if job_record.display_class == "FooJob"
1.0
elsif "default" == queue_name
2.0
else
3.0
end
end Naturally, in this case, it will also support: c.cooldown_period = lambda do |queue_name|
if "default" == queue_name
2.0
else
3.0
end
end |
After giving it another thought, I think we can keep it simple :D just queue name. |
I like the |
I do like it too. But it will involve object creation even when user does not need it (e.g. just caring about queue_name. Thus passing |
84a284b
to
21136ba
Compare
I'm inclined towards |
Will wait with final decision until real case scenario appears. |
The final goal is to allow specify cooldown_period as Proc: Sidekiq::Throttled.configure do |c| c.cooldown_period = lambda do |unit_of_work| unit_of_work.queue == "default" ? 2.0 : 10.0 end end
21136ba
to
01b769d
Compare
Allow
Config#cooldown_period
andConfig#cooldown_threshold
to be specified as Proc:This will go very well in pair with planned push-back strategies PR.