Sha256: 5bca78a73f00b4fba9058d70a8b2533c507ef422c3eacc138ae171fbbb57e0c4

Contents?: true

Size: 1004 Bytes

Versions: 1

Compression:

Stored size: 1004 Bytes

Contents

module Sidekiq::Status::Worker
  include Sidekiq::Status::Storage

  class Stopped < StandardError
  end

  attr_accessor :expiration

  # Stores multiple values into a job's status hash,
  # sets last update time
  # @param [Hash] status_updates updated values
  # @return [String] Redis operation status code
  def store(hash)
    store_for_id @provider_job_id || @job_id || @jid, hash, @expiration
  end

  # Read value from job status hash
  # @param String|Symbol hask key
  # @return [String]
  def retrieve(name)
    read_field_for_id @provider_job_id || @job_id || @jid, name
  end

  # Sets current task progress
  # (inspired by resque-status)
  # @param Fixnum number of tasks done
  # @param String optional message
  # @return [String]
  def at(num, message = nil)
    total(100) if retrieve(:total).nil?
    store(at: num, message: message)
  end

  # Sets total number of tasks
  # @param Fixnum total number of tasks
  # @return [String]
  def total(num)
    store(total: num)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sidekiq-status-0.7.0 lib/sidekiq-status/worker.rb