module SidekiqFakeScheduler

Constants

VERSION

Public Class Methods

work() click to toggle source

Executes all jobs that are due. In contrast to sidekiq's inline mode, this method only executes jobs that were scheduled for now (or any time previous to now). It does not execute jobs that are scheduled for later. This behavior is really powerful in combination with timecop. If any executed job enqueues a new job the new job will get executed as well. The execution order is randomized using +Kernel#rand+

# File lib/sidekiq_fake_scheduler.rb, line 16
def self.work
  loop do
    performed_one = Sidekiq::Worker.jobs.sort_by { rand }.any? do |job|
      JobWrapper.new(job).try_perform
    end

    break unless performed_one
  end
end