Add support for instance-level throttles#1411
Open
tessereth wants to merge 1 commit intoShopify:mainfrom
Open
Conversation
328d34b to
02679f5
Compare
Author
|
The CLA is now signed, I hope you get a chance to take a look at this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've been trying to set up throttles for my maintenance tasks based on configurable values and it's pretty tricky to do in the current code. For instance, I want to be able to configure a database load threshold and tweak the backoff using an attribute. I'm also running the same maintenance task multiple times against different databases and I need different throttle parameters for each. Currently, throttles are set at the class level, so they can't vary per instance.
This PR adds support for per-instance throttles, using basically the same API as the current class-level throttles. Usage looks like:
The throttle conditions array is only accessed here via the instance, so I've just overridden this method:
maintenance_tasks/app/jobs/concerns/maintenance_tasks/task_job_concern.rb
Line 98 in 58e544a
Please let me know what you think. I'm happy to change things if you can think of a better way to achieve the outcomes I'm after.