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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/sidekiq_robust_job/setter_proxy_job.rb', line 3
def build(job_class, options)
Class.new(SimpleDelegator) do
attr_reader :job_class, :custom_options
private :job_class, :custom_options
def initialize(job_class, custom_options = {})
super(job_class)
@job_class = job_class
@custom_options = custom_options
end
def get_sidekiq_options
job_class.get_sidekiq_options.merge(custom_options.stringify_keys)
end
def perform_async(*arguments)
SidekiqRobustJob.perform_async(self, *arguments)
end
def perform_in(interval, *arguments)
SidekiqRobustJob.perform_in(self, interval, *arguments)
end
def perform_at(time, *arguments)
SidekiqRobustJob.perform_at(self, time, *arguments)
end
def set(options = {})
SidekiqRobustJob.set(self, options)
end
def original_perform_in(*args)
call_sidekiq_method(:perform_in, *args)
end
def original_perform_at(*args)
call_sidekiq_method(:perform_at, *args)
end
def original_perform_async(*args)
call_sidekiq_method(:perform_async, *args)
end
def original_set(*args)
call_sidekiq_method(:set, *args)
end
def is_a?(val)
if val == Class
true
else
super
end
end
private
def call_sidekiq_method(name, *args)
Sidekiq::Worker::ClassMethods.instance_method(name).bind(self).call(*args)
end
end.new(job_class, options)
end
|