aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2018-11-11 18:23:13 -0500
committerGeorge Claghorn <george@basecamp.com>2018-11-11 18:23:13 -0500
commit14b5b5afe2bf7369499243931a88db5f40933def (patch)
treef21b9677b8b808be535ed6eb6f0387c2dfd056b3
parenta4d429f4a7c417b719270e9164634c83ded3d0ec (diff)
downloadrails-14b5b5afe2bf7369499243931a88db5f40933def.tar.gz
rails-14b5b5afe2bf7369499243931a88db5f40933def.tar.bz2
rails-14b5b5afe2bf7369499243931a88db5f40933def.zip
Make job queues configurable
-rw-r--r--app/jobs/action_mailbox/incineration_job.rb2
-rw-r--r--app/jobs/action_mailbox/routing_job.rb2
-rw-r--r--lib/action_mailbox.rb1
-rw-r--r--lib/action_mailbox/engine.rb4
4 files changed, 7 insertions, 2 deletions
diff --git a/app/jobs/action_mailbox/incineration_job.rb b/app/jobs/action_mailbox/incineration_job.rb
index 81b381b0d0..4fc0cb0782 100644
--- a/app/jobs/action_mailbox/incineration_job.rb
+++ b/app/jobs/action_mailbox/incineration_job.rb
@@ -1,5 +1,5 @@
class ActionMailbox::IncinerationJob < ActiveJob::Base
- queue_as :action_mailbox_incineration
+ queue_as { ActionMailbox.queues[:incineration] }
discard_on ActiveRecord::RecordNotFound
diff --git a/app/jobs/action_mailbox/routing_job.rb b/app/jobs/action_mailbox/routing_job.rb
index af4aa9f8fa..786187528a 100644
--- a/app/jobs/action_mailbox/routing_job.rb
+++ b/app/jobs/action_mailbox/routing_job.rb
@@ -1,5 +1,5 @@
class ActionMailbox::RoutingJob < ActiveJob::Base
- queue_as :action_mailbox_routing
+ queue_as { ActionMailbox.queues[:routing] }
def perform(inbound_email)
inbound_email.route
diff --git a/lib/action_mailbox.rb b/lib/action_mailbox.rb
index a508e861ac..aec2db7b05 100644
--- a/lib/action_mailbox.rb
+++ b/lib/action_mailbox.rb
@@ -11,4 +11,5 @@ module ActionMailbox
mattr_accessor :ingress
mattr_accessor :logger
mattr_accessor :incinerate_after, default: 30.days
+ mattr_accessor :queues, default: {}
end
diff --git a/lib/action_mailbox/engine.rb b/lib/action_mailbox/engine.rb
index cf438d8f24..e0954e4e49 100644
--- a/lib/action_mailbox/engine.rb
+++ b/lib/action_mailbox/engine.rb
@@ -8,10 +8,14 @@ module ActionMailbox
config.action_mailbox = ActiveSupport::OrderedOptions.new
config.action_mailbox.incinerate_after = 30.days
+ config.action_mailbox.queues = ActiveSupport::InheritableOptions.new \
+ incineration: :action_mailbox_incineration, routing: :action_mailbox_routing
+
initializer "action_mailbox.config" do
config.after_initialize do |app|
ActionMailbox.logger = app.config.action_mailbox.logger || Rails.logger
ActionMailbox.incinerate_after = app.config.action_mailbox.incinerate_after || 30.days
+ ActionMailbox.queues = app.config.action_mailbox.queues || {}
end
end