Module: Sidekiq::Status
- Extended by:
- Storage
- Defined in:
- lib/sidekiq-status/web.rb,
lib/sidekiq-status/version.rb,
lib/sidekiq-status/testing/inline.rb,
lib/sidekiq-status/client_middleware.rb,
lib/sidekiq-status/server_middleware.rb,
lib/sidekiq-status.rb
Overview
adapted from github.com/cryo28/sidekiq_status
Defined Under Namespace
Modules: Storage, Web, Worker Classes: ClientMiddleware, ServerMiddleware
Constant Summary collapse
- VERSION =
"0.5.0"- DEFAULT_EXPIRY =
60 * 30
- STATUS =
%w(queued working complete stopped failed).map(&:to_sym).freeze
Constants included from Storage
Storage::BATCH_LIMIT, Storage::RESERVED_FIELDS
Class Method Summary collapse
-
.at(job_id) ⇒ Object
Methods for retrieving job completion.
- .cancel(job_id, job_unix_time = nil) ⇒ Object (also: unschedule)
-
.get(job_id, field) ⇒ String
Job status by id.
-
.get_all(id) ⇒ Hash
Get all status fields for a job.
- .message(job_id) ⇒ Object
- .pct_complete(job_id) ⇒ Object
- .status(job_id) ⇒ Object
- .total(job_id) ⇒ Object
Class Method Details
.at(job_id) ⇒ Object
Methods for retrieving job completion
48 49 50 |
# File 'lib/sidekiq-status.rb', line 48 def at(job_id) get(job_id, :at).to_i end |
.cancel(job_id, job_unix_time = nil) ⇒ Object Also known as: unschedule
33 34 35 |
# File 'lib/sidekiq-status.rb', line 33 def cancel(job_id, job_unix_time = nil) delete_and_unschedule(job_id, job_unix_time) end |
.get(job_id, field) ⇒ String
Job status by id
17 18 19 |
# File 'lib/sidekiq-status.rb', line 17 def get(job_id, field) read_field_for_id(job_id, field) end |
.get_all(id) ⇒ Hash
Get all status fields for a job
24 25 26 |
# File 'lib/sidekiq-status.rb', line 24 def get_all(id) read_hash_for_id(id) end |
.message(job_id) ⇒ Object
60 61 62 |
# File 'lib/sidekiq-status.rb', line 60 def (job_id) get(job_id, :message) end |
.pct_complete(job_id) ⇒ Object
56 57 58 |
# File 'lib/sidekiq-status.rb', line 56 def pct_complete(job_id) (at(job_id).to_f / total(job_id)) * 100 end |
.status(job_id) ⇒ Object
4 5 6 |
# File 'lib/sidekiq-status/testing/inline.rb', line 4 def status(jid) :complete end |
.total(job_id) ⇒ Object
52 53 54 |
# File 'lib/sidekiq-status.rb', line 52 def total(job_id) get(job_id, :total).to_i end |