module Sidekiq::Status::Worker
Attributes
expiration[RW]
Public Instance Methods
at(num, message = nil)
click to toggle source
Sets current task progress (inspired by resque-status) @param Fixnum number of tasks done @param String optional message @return [String]
# File lib/sidekiq-status/worker.rb, line 29 def at(num, message = nil) @_status_total = 100 if @_status_total.nil? pct_complete = ((num / @_status_total.to_f) * 100).to_i rescue 0 store(at: num, total: @_status_total, pct_complete: pct_complete, message: message, working_at: working_at) end
retrieve(name)
click to toggle source
Read value from job status hash @param String|Symbol hask key @return [String]
# File lib/sidekiq-status/worker.rb, line 20 def retrieve(name) read_field_for_id @provider_job_id || @job_id || @jid || "", name end
store(hash)
click to toggle source
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
# File lib/sidekiq-status/worker.rb, line 13 def store(hash) store_for_id @provider_job_id || @job_id || @jid || "", hash, @expiration end
total(num)
click to toggle source
Sets total number of tasks @param Fixnum total number of tasks @return [String]
# File lib/sidekiq-status/worker.rb, line 38 def total(num) @_status_total = num store(total: num, working_at: working_at) end
Private Instance Methods
working_at()
click to toggle source
# File lib/sidekiq-status/worker.rb, line 45 def working_at @working_at ||= Time.now.to_i end