mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
68c643f8e7
We can split queues on a per environement basis as well as seggregate per application so we can split queues on a per env basis ActiveJob::Base.queue_name_prefix = 'foo'
21 lines
537 B
Ruby
21 lines
537 B
Ruby
module ActiveJob
|
|
module QueueName
|
|
extend ActiveSupport::Concern
|
|
|
|
module ClassMethods
|
|
mattr_accessor(:queue_name_prefix)
|
|
mattr_accessor(:default_queue_name) { "default" }
|
|
|
|
def queue_as(part_name)
|
|
queue_name = part_name.to_s.presence || default_queue_name
|
|
name_parts = [queue_name_prefix.presence, queue_name]
|
|
self.queue_name = name_parts.compact.join('_')
|
|
end
|
|
end
|
|
|
|
included do
|
|
class_attribute :queue_name
|
|
self.queue_name = default_queue_name
|
|
end
|
|
end
|
|
end
|