fix(#4065): make low_prio queue for caching #4200
Merged
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.
Resolves #4065
Description
Adds a "low_priority" delayed job queue. It will currently only have DataCache jobs.
Type of change
How Has This Been Tested?
Job specs were edited to make sure the job is landing the right queue.
Note:
I could not for the life of me figure out how to test that the priority was working.
Based on the delayed job code I believe priority is set when the job is queued, that is when it is written to the database table "delayed_job_queue".
https://github.com/collectiveidea/delayed_job/blob/b66bb64437a8606a414a390531ac73108911434e/lib/delayed/backend/job_preparer.rb#L13
ActiveJob::TestHelper
override thequeue_adapter
fromdelayed_job
to theActiveJob
adapter. This means that priority never gets set from the queue in tests. So if we test:assert_enqueued_with(priority: some_value)
it will always fail. We would have to explicitly set a priority, instead of using the queue priority which doesn't really make sense.Just to sanity check the behavior I ran the following code in
rails c
:the DataCache Jobs were correctly set with the low prio:
NotifyPartnerJob correctly fired off before the caching jobs despite being queued later: