1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Make job queues configurable

This commit is contained in:
George Claghorn 2018-11-11 18:23:13 -05:00
parent a4d429f4a7
commit 14b5b5afe2
4 changed files with 7 additions and 2 deletions

View file

@ -1,5 +1,5 @@
class ActionMailbox::IncinerationJob < ActiveJob::Base
queue_as :action_mailbox_incineration
queue_as { ActionMailbox.queues[:incineration] }
discard_on ActiveRecord::RecordNotFound

View file

@ -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

View file

@ -11,4 +11,5 @@ module ActionMailbox
mattr_accessor :ingress
mattr_accessor :logger
mattr_accessor :incinerate_after, default: 30.days
mattr_accessor :queues, default: {}
end

View file

@ -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