Module: Sidetiq

Defined in:
lib/sidetiq.rb,
lib/sidetiq/web.rb,
lib/sidetiq/clock.rb,
lib/sidetiq/config.rb,
lib/sidetiq/version.rb,
lib/sidetiq/schedule.rb,
lib/sidetiq/middleware.rb,
lib/sidetiq/schedulable.rb

Overview

The Sidetiq namespace.

Defined Under Namespace

Modules: Schedulable, VERSION, Web Classes: Clock, Middleware, Schedule

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Public: Returns the current configuration used by Sidetiq.



21
22
23
# File 'lib/sidetiq/config.rb', line 21

def config
  @config ||= OpenStruct.new
end

.loggerObject

Public: Reader for the Sidetiq logger.

Defaults to ‘Sidekiq.logger`.



27
28
29
# File 'lib/sidetiq.rb', line 27

def logger
  @logger ||= Sidekiq.logger
end

Class Method Details

.configure {|config| ... } ⇒ Object

Public: Configuration wrapper for block configurations.

Examples

Sidetiq.configure do |config|
  config.resolution = 0.2
end

Yields the configuration OpenStruct currently set. Returns nothing.

Yields:



16
17
18
# File 'lib/sidetiq/config.rb', line 16

def configure
  yield config
end

.retries(worker = nil, &block) ⇒ Object

Public: Recurring jobs currently scheduled for retries.

worker - A Sidekiq::Worker class or String of the class name (optional) block - An optional block that can be given to which each

Sidekiq::SortedEntry instance corresponding to a scheduled job will
be yielded.

Examples

Sidetiq.retries
# => [#<Sidekiq::SortedEntry>, ...]

Sidetiq.retries(MyWorker)
# => [#<Sidekiq::SortedEntry>, ...]

Sidetiq.retries("MyWorker")
# => [#<Sidekiq::SortedEntry>, ...]

Sidetiq.retries do |job|
  # do stuff ...
end
# => [#<Sidekiq::SortedEntry>, ...]

Sidetiq.retries(MyWorker) do |job|
  # do stuff ...
end
# => [#<Sidekiq::SortedEntry>, ...]

Sidetiq.retries("MyWorker") do |job|
  # do stuff ...
end
# => [#<Sidekiq::SortedEntry>, ...]

Yields each Sidekiq::SortedEntry instance. Returns an Array of Sidekiq::SortedEntry objects.



117
118
119
# File 'lib/sidetiq.rb', line 117

def retries(worker = nil, &block)
  filter_set(Sidekiq::RetrySet.new, worker, &block)
end

.scheduled(worker = nil, &block) ⇒ Object

Public: Currently scheduled recurring jobs.

worker - A Sidekiq::Worker class or String of the class name (optional) block - An optional block that can be given to which each

Sidekiq::SortedEntry instance corresponding to a scheduled job will
be yielded.

Examples

Sidetiq.scheduled
# => [#<Sidekiq::SortedEntry>, ...]

Sidetiq.scheduled(MyWorker)
# => [#<Sidekiq::SortedEntry>, ...]

Sidetiq.scheduled("MyWorker")
# => [#<Sidekiq::SortedEntry>, ...]

Sidetiq.scheduled do |job|
  # do stuff ...
end
# => [#<Sidekiq::SortedEntry>, ...]

Sidetiq.scheduled(MyWorker) do |job|
  # do stuff ...
end
# => [#<Sidekiq::SortedEntry>, ...]

Sidetiq.scheduled("MyWorker") do |job|
  # do stuff ...
end
# => [#<Sidekiq::SortedEntry>, ...]

Yields each Sidekiq::SortedEntry instance. Returns an Array of Sidekiq::SortedEntry objects.



78
79
80
# File 'lib/sidetiq.rb', line 78

def scheduled(worker = nil, &block)
  filter_set(Sidekiq::ScheduledSet.new, worker, &block)
end

.schedulesObject

Public: Returns a Hash of Sidetiq::Schedule instances.



37
38
39
40
41
# File 'lib/sidetiq.rb', line 37

def schedules
  Clock.synchronize do
    Clock.schedules.dup
  end
end

.workersObject

Public: Returns an Array of workers including Sidetiq::Schedulable.



32
33
34
# File 'lib/sidetiq.rb', line 32

def workers
  schedules.keys
end