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/server_middleware.rb,
lib/sidekiq-status/client_middleware.rb,
lib/sidekiq-status.rb

Overview

Defined Under Namespace

Modules: Storage, Web, Worker Classes: ClientMiddleware, ServerMiddleware

Constant Summary collapse

VERSION =
'0.6.0'
DEFAULT_EXPIRY =
60 * 30
STATUS =
[ :queued, :working, :complete, :stopped, :failed, :interrupted ].freeze

Constants included from Storage

Storage::BATCH_LIMIT, Storage::RESERVED_FIELDS

Class Method Summary collapse

Class Method Details

.at(job_id) ⇒ Object

Methods for retrieving job completion


46
47
48
# File 'lib/sidekiq-status.rb', line 46

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


58
59
60
# File 'lib/sidekiq-status.rb', line 58

def message(job_id)
  get(job_id, :message)
end

.pct_complete(job_id) ⇒ Object


54
55
56
# File 'lib/sidekiq-status.rb', line 54

def pct_complete(job_id)
  ((at(job_id) / total(job_id).to_f) * 100 ).to_i if total(job_id).to_f > 0
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


50
51
52
# File 'lib/sidekiq-status.rb', line 50

def total(job_id)
  get(job_id, :total).to_i
end