yawl 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/yawl.rb +1 -0
- data/lib/yawl/process.rb +1 -1
- data/lib/yawl/setup.rb +2 -0
- data/lib/yawl/step.rb +22 -14
- data/lib/yawl/steps/base.rb +0 -3
- data/lib/yawl/utils.rb +17 -0
- data/lib/yawl/version.rb +1 -1
- data/spec/lib/step_spec.rb +2 -2
- metadata +5 -6
- data/migrations/01_setup_tables.rb +0 -34
- data/migrations/02_setup_queue_classic.rb +0 -14
data/lib/yawl.rb
CHANGED
data/lib/yawl/process.rb
CHANGED
data/lib/yawl/setup.rb
CHANGED
data/lib/yawl/step.rb
CHANGED
@@ -79,25 +79,33 @@ module Yawl
|
|
79
79
|
attempt.update(:output => real_step.output, :completed_at => Time.now)
|
80
80
|
update(:state => "completed")
|
81
81
|
process.step_finished
|
82
|
-
rescue Step::Fatal, Step::Tired, StandardError, SignalException => e
|
83
|
-
log(:fn => "execute", :at => "caught_exception", :class => e.class, :message => e.message)
|
84
|
-
attempt.update(:output => "#{real_step.output}\n\n---\nCAUGHT ERROR: #{e}\n#{e.backtrace.join("\n")}\n", :completed_at => Time.now)
|
85
82
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
update(:state => "pending")
|
95
|
-
start_after_delay
|
96
|
-
end
|
83
|
+
rescue Step::Tired => e
|
84
|
+
log(:fn => "execute", :at => "sleep")
|
85
|
+
attempt.update(:output => "#{real_step.output}\n\n---\n#{e}\n", :completed_at => Time.now)
|
86
|
+
handle_error(e)
|
87
|
+
rescue Step::Fatal, StandardError, SignalException => e
|
88
|
+
attempt.update(:output => "#{real_step.output}\n\n---\nCAUGHT ERROR: #{e}\n#{e.backtrace.join("\n")}\n", :completed_at => Time.now)
|
89
|
+
log(:fn => "execute", :at => "caught_exception", :class => e.class, :message => e.message)
|
90
|
+
handle_error(e)
|
97
91
|
end
|
98
92
|
end
|
99
93
|
end
|
100
94
|
|
95
|
+
def handle_error(e)
|
96
|
+
if out_of_attempts? || e.is_a?(Step::Fatal)
|
97
|
+
update(:state => "failed")
|
98
|
+
process.step_failed
|
99
|
+
raise
|
100
|
+
elsif SignalException === e && e.signm == "SIGTERM" # we are shutting down
|
101
|
+
update(:state => "interrupted")
|
102
|
+
raise
|
103
|
+
else
|
104
|
+
update(:state => "pending")
|
105
|
+
start_after_delay
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
101
109
|
def to_public_h
|
102
110
|
{
|
103
111
|
"seq" => seq,
|
data/lib/yawl/steps/base.rb
CHANGED
data/lib/yawl/utils.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Yawl
|
2
|
+
module Utils
|
3
|
+
extend self
|
4
|
+
|
5
|
+
# from activesupport
|
6
|
+
def constantize(camel_cased_word)
|
7
|
+
names = camel_cased_word.split('::')
|
8
|
+
names.shift if names.empty? || names.first.empty?
|
9
|
+
|
10
|
+
constant = Object
|
11
|
+
names.each do |name|
|
12
|
+
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
13
|
+
end
|
14
|
+
constant
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/yawl/version.rb
CHANGED
data/spec/lib/step_spec.rb
CHANGED
@@ -325,7 +325,7 @@ describe Yawl::Step do
|
|
325
325
|
it "captures output" do
|
326
326
|
step.execute
|
327
327
|
|
328
|
-
step.attempts.first.output.should =~ /\AI started\n\n\n---\
|
328
|
+
step.attempts.first.output.should =~ /\AI started\n\n\n---\nStep slept\n\Z/
|
329
329
|
end
|
330
330
|
end
|
331
331
|
|
@@ -361,7 +361,7 @@ describe Yawl::Step do
|
|
361
361
|
it "captures output" do
|
362
362
|
expect { step.execute }.to raise_error
|
363
363
|
|
364
|
-
step.attempts.first.output.should =~ /\AI started\n\n\n---\
|
364
|
+
step.attempts.first.output.should =~ /\AI started\n\n\n---\nStep slept\n\Z/
|
365
365
|
end
|
366
366
|
end
|
367
367
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yawl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
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: 2014-
|
12
|
+
date: 2014-04-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sequel
|
@@ -149,10 +149,9 @@ files:
|
|
149
149
|
- lib/yawl/step.rb
|
150
150
|
- lib/yawl/step_attempt.rb
|
151
151
|
- lib/yawl/steps/base.rb
|
152
|
+
- lib/yawl/utils.rb
|
152
153
|
- lib/yawl/version.rb
|
153
154
|
- lib/yawl/worker.rb
|
154
|
-
- migrations/01_setup_tables.rb
|
155
|
-
- migrations/02_setup_queue_classic.rb
|
156
155
|
- spec/lib/process_spec.rb
|
157
156
|
- spec/lib/step_spec.rb
|
158
157
|
- spec/spec_helper.rb
|
@@ -172,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
172
171
|
version: '0'
|
173
172
|
segments:
|
174
173
|
- 0
|
175
|
-
hash:
|
174
|
+
hash: -3845304480906963772
|
176
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
176
|
none: false
|
178
177
|
requirements:
|
@@ -181,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
180
|
version: '0'
|
182
181
|
segments:
|
183
182
|
- 0
|
184
|
-
hash:
|
183
|
+
hash: -3845304480906963772
|
185
184
|
requirements: []
|
186
185
|
rubyforge_project:
|
187
186
|
rubygems_version: 1.8.23
|
@@ -1,34 +0,0 @@
|
|
1
|
-
Sequel.migration do
|
2
|
-
change do
|
3
|
-
create_table(:processes) do
|
4
|
-
primary_key :id
|
5
|
-
String :desired_state, :text=>true, :null=>false
|
6
|
-
String :state, :default=>"pending", :text=>true, :null=>false
|
7
|
-
DateTime :created_at
|
8
|
-
String :name, :text=>true
|
9
|
-
String :config
|
10
|
-
String :request_id, :text=>true
|
11
|
-
String :specified_attributes
|
12
|
-
end
|
13
|
-
|
14
|
-
create_table(:steps) do
|
15
|
-
primary_key :id
|
16
|
-
Integer :process_id, :null=>false
|
17
|
-
Integer :seq, :null=>false
|
18
|
-
String :name, :text=>true, :null=>false
|
19
|
-
String :state, :default=>"pending", :text=>true, :null=>false
|
20
|
-
|
21
|
-
index [:process_id]
|
22
|
-
end
|
23
|
-
|
24
|
-
create_table(:step_attempts) do
|
25
|
-
primary_key :id
|
26
|
-
Integer :step_id, :null=>false
|
27
|
-
File :output
|
28
|
-
DateTime :started_at
|
29
|
-
DateTime :completed_at
|
30
|
-
|
31
|
-
index [:step_id]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|