task-orchestrator 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/examples/failure_handler +11 -0
- data/examples/sequential +1 -1
- data/lib/orchestrator/task.rb +18 -10
- data/lib/orchestrator/version.rb +1 -1
- metadata +3 -2
data/README.md
CHANGED
data/examples/sequential
CHANGED
data/lib/orchestrator/task.rb
CHANGED
@@ -78,7 +78,19 @@ module Orchestrator
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
+
def validate_command(command,error_prefix)
|
82
|
+
if command.is_a?(String)
|
83
|
+
command = { 'command' => interpolate_command(command) }
|
84
|
+
elsif command.is_a?(Hash)
|
85
|
+
invalid(error_prefix + " command is invalid") unless command.has_key?('command') && command.is_a?(String)
|
86
|
+
command['command'] = interpolate_command(command['command'])
|
87
|
+
else
|
88
|
+
invalid(error_prefix + " is invalid")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
81
92
|
def validate_config
|
93
|
+
@state['failure_handler'] = validate_command(@state['failure_handler'], 'task failure handler') if @state.has_key?('failure_handler')
|
82
94
|
if @state.has_key?('email')
|
83
95
|
invalid("config email recipients is missing or invalid") unless @state['email'].has_key?('recipients') && @state['email']['recipients'].is_a?(String) || @state['email']['recipients'].is_a?(Array)
|
84
96
|
invalid("config email from is missing or invalid") unless @state['email'].has_key?('from') && @state['email']['from'].is_a?(String)
|
@@ -97,21 +109,16 @@ module Orchestrator
|
|
97
109
|
invalid("task step has no type") unless step.has_key?('type') && step['type'].is_a?(String)
|
98
110
|
invalid("task step type #{step['type']} is invalid") unless [:parallel,:sequential].find_index(step['type'].to_sym)
|
99
111
|
invalid("task step scripts is missing or invalid") unless step.has_key?('scripts') && step['scripts'].is_a?(Array)
|
112
|
+
step['failure_handler'] = validate_command(step['failure_handler'], 'task failure handler') if step.has_key?('failure_handler')
|
100
113
|
step['scripts'].each_index do |index|
|
101
|
-
|
102
|
-
step['scripts'][index] = { 'command' => interpolate_command(step['scripts'][index]) }
|
103
|
-
elsif step['scripts'][index].is_a?(Hash)
|
104
|
-
invalid("task step script command is invalid") unless step['scripts'][index].has_key?('command') && step['scripts'][index]['command'].is_a?(String)
|
105
|
-
step['scripts'][index]['command'] = interpolate_command(step['scripts'][index]['command'])
|
106
|
-
else
|
107
|
-
invalid("task script is invalid")
|
108
|
-
end
|
114
|
+
step['scripts'][index] = validate_command(step['scripts'][index], 'task step script')
|
109
115
|
end
|
110
116
|
end
|
111
117
|
end
|
112
118
|
|
113
119
|
def fail
|
114
|
-
|
120
|
+
run_script(@failure_handler) if @failure_handler
|
121
|
+
run_script(@state['failure_handler']) if @state.has_key?('failure_handler')
|
115
122
|
|
116
123
|
Pony.mail(
|
117
124
|
:to => @state['email']['recipients'],
|
@@ -238,12 +245,13 @@ EOF
|
|
238
245
|
@retry_delay = step.has_key?('retry_delay') ? step['retry_delay'] : 0
|
239
246
|
@on_week_days = step.has_key?('on_week_days') ? step['on_week_days'].map{|d| "#{d}?".downcase.to_sym} : [ :sunday?, :monday?, :tuesday?, :wednesday?, :thursday?, :friday?, :saturday? ]
|
240
247
|
@on_month_days = step.has_key?('on_month_days') ? step['on_month_days'] : (1..31).to_a
|
248
|
+
@failure_handler = step.has_key?('failure_handler') ? step['failure_handler'] : nil
|
241
249
|
|
242
250
|
if step['type'].to_sym == :parallel and @on_week_days.map {|d| Time.now.send(d) }.find_index(true) and @on_month_days.find_index(Time.now.mday)
|
243
251
|
#Parallel
|
244
252
|
interval = step.has_key?('sleep') ? step['sleep'] : 1
|
245
|
-
@on_failure = step.has_key?('on_failure') ? step['on_failure'].to_sym : :finish
|
246
253
|
parallel_factor = step.has_key?('parallel') ? step['parallel'] : 1
|
254
|
+
@on_failure = step.has_key?('on_failure') ? step['on_failure'].to_sym : :finish
|
247
255
|
|
248
256
|
@threads = Hash.new
|
249
257
|
index = 0
|
data/lib/orchestrator/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: task-orchestrator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pony
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/orchestrator/version.rb
|
90
90
|
- lib/orchestrator/cli.rb
|
91
91
|
- examples/sequential
|
92
|
+
- examples/failure_handler
|
92
93
|
- examples/multistep
|
93
94
|
- examples/parallel
|
94
95
|
- examples/interpolation
|