-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsample_job.rb
109 lines (88 loc) · 1.57 KB
/
sample_job.rb
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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
module ExecuteLog
def self.store
@store ||= {}
end
end
class Notifier
def after_run(job)
puts "#{job.name}:#{job.state.name}:#{job.elapsed_time_from}"
end
end
class SampleJob < Rukawa::Job
def run
sleep rand(5)
ExecuteLog.store[self.class] = Time.now
end
end
class Job1 < SampleJob
set_description "Job1 description body"
after_run Notifier.new
def run
p variables unless variables.empty?
super
end
end
class Job2 < SampleJob
after_fail do |job|
p "Job2 Failed!!! #{job.state.name}"
end
def run
raise "job2 error"
end
end
class Job3 < SampleJob
end
class Job4 < SampleJob
# inherited by subclass
set_dependency_type :one_success
set_resource_count 3
end
class Job5 < SampleJob
# inherited by subclass
set_retryable limit: 3, wait: 2, type: RuntimeError
def run
raise "job5 error"
end
end
class Job6 < SampleJob
set_dependency_type :one_failed
end
class Job7 < SampleJob
end
class Job8 < SampleJob
end
class InnerJob1 < SampleJob
end
class InnerJob2 < SampleJob
def run
raise "inner job2 error"
end
end
class InnerJob3 < SampleJob
end
class InnerJob4 < SampleJob
end
class InnerJob5 < SampleJob
# inherited by subclass
add_skip_rule ->(job) { job.is_a?(SampleJob) }
end
class InnerJob6 < SampleJob
end
class InnerJob7 < SampleJob
end
class InnerJob8 < SampleJob
end
class InnerJob9 < SampleJob
end
class InnerJob10 < SampleJob
end
class InnerJob11 < SampleJob
end
class InnerJob12 < SampleJob
end
class InnerJob13 < SampleJob
end
class NestedJob1 < SampleJob
end
class NestedJob2 < SampleJob
end