class Sidekiq::Workers

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

Defined in:

sidekiq/api.cr

Instance Method Summary

Instance Method Detail

def each(&) #
Description copied from module Enumerable(Sidekiq::WorkerEntry)

Must yield this collection's elements to the block.


[View source]
def size #

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.


[View source]