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
|
# File 'lib/skynet/object_extensions.rb', line 3
def send_later(method, *arguments, &block)
raise ArgumentError("send_later can not serialize blocks.") if block_given?
if is_a?(Class) or is_a?(Module)
data = {
:class_name => name,
:method => method,
:arguments => arguments
}.to_yaml
else
data = {
:object => self,
:method => method,
:arguments => arguments
}.to_yaml
end
jobopts = {
:single => true,
:mappers => 1,
:map_data => [data],
:name => "send_later #{data[:class_name] ? "#{self}.#{method}" : "#{self.class}##{method}"}",
:map_name => "",
:map_timeout => 2.minutes,
:reduce_timeout => 2.minutes,
:master_timeout => 2.minutes,
:master_result_timeout => 2.minutes,
:map_reduce_class => Skynet::ObjectAsync,
:master_retry => 0,
:map_retry => 0
}
job = Skynet::AsyncJob.new(jobopts)
job.run
end
|