Flowdock
method

queue_with_priority

Importance_1
v7.1.3.2 - Show latest stable - 0 notes - Class: ClassMethods
queue_with_priority(priority = nil, &block) public

Specifies the priority of the queue to create the job with.

class PublishToFeedJob < ActiveJob::Base
  queue_with_priority 50

  def perform(post)
    post.to_feed!
  end
end

Can be given a block that will evaluate in the context of the job so that a dynamic priority can be applied:

class PublishToFeedJob < ApplicationJob
  queue_with_priority do
    post = self.arguments.first

    if post.paid?
      10
    else
      50
    end
  end

  def perform(post)
    post.to_feed!
  end
end
Show source
Register or log in to add new notes.