class Sidekiq::Workers
- Sidekiq::Workers
- Reference
- Object
Overview
A worker is a thread that is currently processing a job. Programmatic access to the current active worker set.
WARNING WARNING WARNING
This is live data that changes second by second. If you call #size => 5 and then expect #each to be called 5 times, you're going to have a bad time.
workers = Sidekiq::Workers.new workers.size => 2 workers.each do |process_id, thread_id, work| # process_id is a unique identifier per Sidekiq process # thread_id is a unique identifier per thread # work is a Hash which looks like: # { "queue" => name, "run_at" => timestamp, "payload" => msg } # run_at is an epoch Integer. end
Included Modules
- Enumerable(Sidekiq::WorkerEntry)
Defined in:
sidekiq/api.crInstance Method Summary
-
#each(&)
Must yield this collection's elements to the block.
-
#size
Note that #size is only as accurate as Sidekiq's heartbeat, which happens every 5 seconds.
Instance Method Detail
Must yield this collection's elements to the block.
Note that #size is only as accurate as Sidekiq's heartbeat, which happens every 5 seconds. It is NOT real-time.
Not very efficient if you have lots of Sidekiq processes but the alternative is a global counter which can easily get out of sync with crashy processes.