Module: Sidekiq::TestingClient

Included in:
Client
Defined in:
lib/sidekiq/testing.rb

Instance Method Summary collapse

Instance Method Details

#atomic_push(conn, payloads) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/sidekiq/testing.rb', line 86

def atomic_push(conn, payloads)
  if Sidekiq::Testing.fake?
    payloads.each do |job|
      job = Sidekiq.load_json(Sidekiq.dump_json(job))
      job["enqueued_at"] = Time.now.to_f unless job["at"]
      Queues.push(job["queue"], job["class"], job)
    end
    true
  elsif Sidekiq::Testing.inline?
    payloads.each do |job|
      klass = Object.const_get(job["class"])
      job["id"] ||= SecureRandom.hex(12)
      job_hash = Sidekiq.load_json(Sidekiq.dump_json(job))
      klass.process_job(job_hash)
    end
    true
  else
    super
  end
end