blob: 713da08359a364e636932e1aa9db537373d0fc2c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
require 'sucker_punch'
module ActiveJob
module QueueAdapters
class SuckerPunchAdapter
class << self
def queue(job, *args)
JobWrapper.new.async.perform(job, *args)
end
def queue_at(job, timestamp, *args)
secs = Time.now.to_f - timestamp
if secs < 1
# Optimization to enqueue something now that is scheduled to go out now or in the past
JobWrapper.new.async.perform(job, *args)
else
JobWrapper.new.async.later(secs, job, *args)
end
end
end
class JobWrapper
include SuckerPunch::Job
def perform(job_name, *args)
job_name.new.perform *Parameters.deserialize(args)
end
def later(sec, job_name, *args)
after(sec) { p args; perform(job_name, *args) }
end
end
end
end
end
|