跳至内容 跳至搜索

包含用于更改活动队列适配器的 setter 方法。

方法
Q

常量

QUEUE_ADAPTER_METHODS = [:enqueue, :enqueue_at].freeze
 

实例公共方法

queue_adapter()

返回后端队列提供程序。默认队列适配器是 :async。有关更多信息,请参阅 QueueAdapters

# File activejob/lib/active_job/queue_adapter.rb, line 34
def queue_adapter
  self.queue_adapter = :async if _queue_adapter.nil?
  _queue_adapter
end

queue_adapter=(name_or_adapter)

指定后端队列提供程序。默认队列适配器是 :async 队列。有关更多信息,请参阅 QueueAdapters

# File activejob/lib/active_job/queue_adapter.rb, line 49
def queue_adapter=(name_or_adapter)
  case name_or_adapter
  when Symbol, String
    queue_adapter = ActiveJob::QueueAdapters.lookup(name_or_adapter).new
    queue_adapter.try(:check_adapter)
    assign_adapter(name_or_adapter.to_s, queue_adapter)
  else
    if queue_adapter?(name_or_adapter)
      adapter_name = ActiveJob.adapter_name(name_or_adapter).underscore
      assign_adapter(adapter_name, name_or_adapter)
    else
      raise ArgumentError
    end
  end
end

queue_adapter_name()

返回表示配置的队列适配器名称的字符串。默认情况下返回 "async"

# File activejob/lib/active_job/queue_adapter.rb, line 41
def queue_adapter_name
  self.queue_adapter = :async if _queue_adapter_name.nil?
  _queue_adapter_name
end