9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/shoryuken/later/worker.rb', line 9
def perform_later(time, body, options = {})
time = Time.now + time.to_i if time.is_a?(Numeric)
time = time.to_time if time.respond_to?(:to_time)
raise ArgumentError, 'expected Numeric, Time but got '+time.class.name unless Time===time
if time < Time.now + Shoryuken::Later::MAX_QUEUE_DELAY
perform_in(time, body, options)
else
table = get_shoryuken_options['schedule_table'] || Shoryuken::Later.default_table
args = JSON.dump(body: body, options: options)
Shoryuken::Later::Client.create_item(table, perform_at: time.to_i, shoryuken_args: args,
shoryuken_class: self.to_s)
end
end
|