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:
parent
a4d429f4a7
commit
14b5b5afe2
4 changed files with 7 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
class ActionMailbox::IncinerationJob < ActiveJob::Base
|
||||
queue_as :action_mailbox_incineration
|
||||
queue_as { ActionMailbox.queues[:incineration] }
|
||||
|
||||
discard_on ActiveRecord::RecordNotFound
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -11,4 +11,5 @@ module ActionMailbox
|
|||
mattr_accessor :ingress
|
||||
mattr_accessor :logger
|
||||
mattr_accessor :incinerate_after, default: 30.days
|
||||
mattr_accessor :queues, default: {}
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue