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

Instance Method Summary collapse

Instance Attribute Details

#expirationObject

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)

Parameters:

  • Fixnum

    number of tasks done

  • String

    optional message

Returns:

  • (String)

29
30
31
32
# File 'lib/sidekiq-status/worker.rb', line 29

def at(num, message = nil)
  total(100) if retrieve(:total).nil?
  store(at: num, message: message)
end

#retrieve(name) ⇒ String

Read value from job status hash

Parameters:

  • String|Symbol

    hask key

Returns:

  • (String)

20
21
22
# File 'lib/sidekiq-status/worker.rb', line 20

def retrieve(name)
  read_field_for_id @jid, name
end

#store(hash) ⇒ String

Stores multiple values into a job's status hash, sets last update time

Parameters:

  • status_updates (Hash)

    updated values

Returns:

  • (String)

    Redis operation status code


13
14
15
# File 'lib/sidekiq-status/worker.rb', line 13

def store(hash)
  store_for_id @jid, hash, @expiration
end

#total(num) ⇒ String

Sets total number of tasks

Parameters:

  • Fixnum

    total number of tasks

Returns:

  • (String)

37
38
39
# File 'lib/sidekiq-status/worker.rb', line 37

def total(num)
  store(total: num)
end