-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #461 from slovensko-digital/GO-75/jobs_priority
GO-75 Set jobs priority
- Loading branch information
Showing
29 changed files
with
183 additions
and
51 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,48 @@ | ||
class ApplicationJob < ActiveJob::Base | ||
include Rollbar::ActiveJob | ||
|
||
queue_as :default | ||
|
||
attr_accessor :job_context | ||
|
||
def set(options = {}) | ||
# :nodoc: | ||
self.job_context = options[:job_context] | ||
super | ||
end | ||
|
||
def serialize | ||
super.merge( | ||
job_context: job_context | ||
) | ||
end | ||
|
||
def deserialize(job_data) | ||
super | ||
self.job_context = job_data["job_context"] | ||
end | ||
|
||
before_enqueue do |job| | ||
job.job_context = Thread.current[:job_context] if Thread.current[:job_context].present? | ||
job.queue_name = job.job_context if job.job_context.present? | ||
end | ||
|
||
around_perform do |job, block| | ||
Thread.current[:job_context] = job.job_context if job.job_context.present? | ||
block.call | ||
ensure | ||
Thread.current[:job_context] = nil | ||
end | ||
|
||
queue_with_priority do | ||
case queue_name.to_sym | ||
when :asap then -1000 | ||
when :default, :automation then 0 | ||
when :later then 1000 | ||
else | ||
raise "Unable to assign default priority to a job on #{queue_name} queue" | ||
end | ||
end | ||
|
||
retry_on StandardError, wait: :polynomially_longer, attempts: Float::INFINITY | ||
end |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
2 changes: 0 additions & 2 deletions
2
app/jobs/searchable/reindex_message_threads_with_tag_id_job.rb
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,6 @@ two: | |
message_object: ssd_main_general_two_form | ||
blob: MyText | ||
|
||
main_draft: | ||
message_object: ssd_main_draft_form | ||
blob: <GeneralAgenda xmlns="http://schemas.gov.sk/form/App.GeneralAgenda/1.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><subject>predmet</subject><text>text</text></GeneralAgenda> | ||
|
||
draft_two: | ||
message_object: ssd_main_general_draft_two_form | ||
blob: <GeneralAgenda xmlns="http://schemas.gov.sk/form/App.GeneralAgenda/1.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><subject>predmet</subject><text>text</text></GeneralAgenda> | ||
|
@@ -24,6 +20,10 @@ empty_draft: | |
message_object: ssd_main_empty_draft_form | ||
blob: <GeneralAgenda xmlns="http://schemas.gov.sk/form/App.GeneralAgenda/1.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><subject></subject><text></text></GeneralAgenda> | ||
|
||
ssd_main_draft_form_data: | ||
message_object: ssd_main_draft_form | ||
blob: <GeneralAgenda xmlns="http://schemas.gov.sk/form/App.GeneralAgenda/1.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><subject>predmet</subject><text>text</text></GeneralAgenda> | ||
|
||
fs_one: | ||
message_object: ssd_main_fs_one_form | ||
blob: <n0:ElectronicOfficialDocument xmlns:n0="http://schemas.gov.sk/form/42499500.FS_EUD_v1_0.sk/1.6"> <n0:Sender> <n0:PersonData> <n0:CorporateBody> <n0:FinancialAdministrationAuthority>Daňový úrad Bratislava</n0:FinancialAdministrationAuthority> </n0:CorporateBody> <n0:PhysicalAddress> <n0:AddressLine>Ševčenkova 32, 850 00 Bratislava</n0:AddressLine> </n0:PhysicalAddress> </n0:PersonData> </n0:Sender> <n0:Document> <n0:DocumentReference>000000000/2022</n0:DocumentReference> <n0:ContactPerson>Mgr. X Y</n0:ContactPerson> <n0:PhoneNumber>02/00000000</n0:PhoneNumber> <n0:EmailAddress>[email protected]</n0:EmailAddress> <n0:IssuePlace>Bratislava</n0:IssuePlace> <n0:IssueDate>2022-04-19</n0:IssueDate> <n0:Subject>Rozhodnutie</n0:Subject> </n0:Document></n0:ElectronicOfficialDocument> |
This file contains 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
This file contains 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
Oops, something went wrong.