6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/sidetiq/handler.rb', line 6
def dispatch(worker, tick)
schedule = worker.schedule
return unless schedule.schedule_next?(tick)
Lock::Redis.new(worker).synchronize do |redis|
if schedule.backfill? && (last = worker.last_scheduled_occurrence) > 0
last = Sidetiq.config.utc ? Time.at(last).utc : Time.at(last)
schedule.occurrences_between(last + 1, tick).each do |past_t|
enqueue(worker, past_t, redis)
end
end
enqueue(worker, schedule.next_occurrence(tick), redis)
end
rescue StandardError => e
handle_exception(e, context: "Sidetiq::Handler#dispatch")
raise e
end
|