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
|
# File 'lib/skynet/skynet_active_record_extensions.rb', line 2
def send_later(method,opts=nil,save=nil)
raise NoMethodError.new("Method: #{method} doesn't exist in #{self.class}") unless self.respond_to?(method)
data = {
:model_class => self.class.to_s,
:model_id => self.id,
:method => method,
}
data[:save] = 1 if save
data[:opts] = opts.to_yaml if opts
jobopts = {
:single => true,
:mappers => 1,
:map_data => [data],
:name => "send_later #{self.class}##{method}",
:map_name => "",
:map_timeout => 60,
:reduce_timeout => 60,
:master_timeout => 60,
:master_result_timeout => 1.minute,
:map_reduce_class => Skynet::ActiveRecordAsync,
:master_retry => 0,
:map_retry => 0
}
job = Skynet::AsyncJob.new(jobopts)
job.run
end
|