Module: Sidekiq::Status::Worker
- Includes:
- Storage
- Defined in:
- lib/sidekiq-status/worker.rb
Defined Under Namespace
Classes: Stopped
Constant Summary
Constants included from Storage
Storage::BATCH_LIMIT, Storage::RESERVED_FIELDS
Instance Attribute Summary collapse
-
#expiration ⇒ Object
Returns the value of attribute expiration.
Instance Method Summary collapse
-
#at(num, message = nil) ⇒ String
Sets current task progress (inspired by resque-status).
-
#retrieve(name) ⇒ String
Read value from job status hash.
-
#store(hash) ⇒ String
Stores multiple values into a job’s status hash, sets last update time.
-
#total(num) ⇒ String
Sets total number of tasks.
Instance Attribute Details
#expiration ⇒ Object
Returns the value of attribute expiration.
7 8 9 |
# File 'lib/sidekiq-status/worker.rb', line 7 def expiration @expiration end |
Instance Method Details
#at(num, message = nil) ⇒ String
Sets current task progress (inspired by resque-status)
29 30 31 32 33 |
# File 'lib/sidekiq-status/worker.rb', line 29 def at(num, = 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: , working_at: working_at) end |
#retrieve(name) ⇒ String
Read value from job status hash
20 21 22 |
# 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) ⇒ String
Stores multiple values into a job’s status hash, sets last update time
13 14 15 |
# 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) ⇒ String
Sets total number of tasks
38 39 40 41 |
# File 'lib/sidekiq-status/worker.rb', line 38 def total(num) @_status_total = num store(total: num, working_at: working_at) end |