class Sidekiq::Throttled::Fetch::UnitOfWork
BRPOP response envelope.
@see Throttled::Fetch
@private
Attributes
@return [String] Job's JSON payload
@return [String] Redis key where job was pulled from
Public Class Methods
@param [String] queue Redis key where job was pulled from @param [String] job Job's JSON payload
# File lib/sidekiq/throttled/fetch/unit_of_work.rb, line 23 def initialize(queue, job) @queue = queue @job = job end
Public Instance Methods
Callback that is called by `Sidekiq::Processor` when job was succeccfully processed. Most likely this is used by `ReliableFetch` of Sidekiq
Pro/Enterprise to remove job from running queue.
@return [void]
# File lib/sidekiq/throttled/fetch/unit_of_work.rb, line 33 def acknowledge # do nothing end
Normalized `queue` name.
@see QueueName.normalize
@return [String]
# File lib/sidekiq/throttled/fetch/unit_of_work.rb, line 41 def queue_name @queue_name ||= QueueName.normalize queue end
Pushes job back to the tail of the queue, so that it will be popped first next time fetcher will pull job.
@note This is triggered when job was not finished and Sidekiq
server
process was terminated. It is a reverse of whatever fetcher was doing to pull the job out of queue.
@return [void]
# File lib/sidekiq/throttled/fetch/unit_of_work.rb, line 53 def requeue Sidekiq.redis { |conn| conn.rpush(QueueName.expand(queue_name), job) } end
Pushes job back to the head of the queue, so that job won't be tried immediately after it was requeued (in most cases).
@note This is triggered when job is throttled. So it is same operation
Sidekiq performs upon `Sidekiq::Worker.perform_async` call.
@return [void]
# File lib/sidekiq/throttled/fetch/unit_of_work.rb, line 64 def requeue_throttled Sidekiq.redis { |conn| conn.lpush(QueueName.expand(queue_name), job) } end
Tells whenever job should be pushed back to queue (throttled) or not.
@see Sidekiq::Throttled.throttled?
@return [Boolean]
# File lib/sidekiq/throttled/fetch/unit_of_work.rb, line 72 def throttled? Throttled.throttled? job end