bumbleworks 0.0.19 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/bumbleworks.rb +1 -1
- data/lib/bumbleworks/ruote.rb +17 -0
- data/lib/bumbleworks/version.rb +1 -1
- data/spec/lib/bumbleworks/ruote_spec.rb +38 -0
- data/spec/lib/bumbleworks_spec.rb +5 -0
- metadata +2 -2
data/lib/bumbleworks.rb
CHANGED
@@ -24,7 +24,7 @@ module Bumbleworks
|
|
24
24
|
def_delegators :configuration, setting, "#{setting.to_s}="
|
25
25
|
end
|
26
26
|
|
27
|
-
def_delegators Bumbleworks::Ruote, :dashboard, :start_worker!
|
27
|
+
def_delegators Bumbleworks::Ruote, :dashboard, :start_worker!, :cancel_all_processes!
|
28
28
|
def_delegator Bumbleworks::ProcessDefinition, :define, :define_process
|
29
29
|
|
30
30
|
# @public
|
data/lib/bumbleworks/ruote.rb
CHANGED
@@ -2,6 +2,8 @@ require "ruote"
|
|
2
2
|
|
3
3
|
module Bumbleworks
|
4
4
|
class Ruote
|
5
|
+
class CancelTimeout < StandardError; end
|
6
|
+
|
5
7
|
class << self
|
6
8
|
def dashboard(options = {})
|
7
9
|
@dashboard ||= begin
|
@@ -41,6 +43,21 @@ module Bumbleworks
|
|
41
43
|
dashboard.launch(dashboard.variables[name], *args)
|
42
44
|
end
|
43
45
|
|
46
|
+
def cancel_all_processes!(options = {})
|
47
|
+
options[:timeout] ||= 5
|
48
|
+
dashboard.processes.each do |ps|
|
49
|
+
dashboard.cancel(ps.wfid)
|
50
|
+
end
|
51
|
+
|
52
|
+
cancel_start_time = Time.now
|
53
|
+
while dashboard.processes.count > 0
|
54
|
+
if (Time.now - cancel_start_time) > options[:timeout]
|
55
|
+
raise CancelTimeout, "Cancel taking too long - #{dashboard.processes.count} processes remain"
|
56
|
+
end
|
57
|
+
sleep 0.1
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
44
61
|
def register_participants(&block)
|
45
62
|
dashboard.register(&block) if block
|
46
63
|
set_catchall_if_needed
|
data/lib/bumbleworks/version.rb
CHANGED
@@ -3,6 +3,44 @@ describe Bumbleworks::Ruote do
|
|
3
3
|
Bumbleworks.reset!
|
4
4
|
end
|
5
5
|
|
6
|
+
describe ".cancel_all_processes!" do
|
7
|
+
before :each do
|
8
|
+
Bumbleworks.storage = {}
|
9
|
+
Bumbleworks::Ruote.register_participants
|
10
|
+
Bumbleworks.start_worker!
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'cancels all processes' do
|
14
|
+
5.times do |i|
|
15
|
+
Bumbleworks.define_process "do_nothing_#{i}" do
|
16
|
+
participant :ref => "lazy_guy_#{i}", :task => 'absolutely_nothing'
|
17
|
+
end
|
18
|
+
Bumbleworks.launch!("do_nothing_#{i}")
|
19
|
+
Bumbleworks.dashboard.wait_for("lazy_guy_#{i}".to_sym)
|
20
|
+
end
|
21
|
+
Bumbleworks.dashboard.processes.count.should == 5
|
22
|
+
described_class.cancel_all_processes!
|
23
|
+
Bumbleworks.dashboard.processes.count.should == 0
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'times out if processes are not cancelled in time' do
|
27
|
+
Bumbleworks.define_process "time_hog" do
|
28
|
+
sequence :on_cancel => 'ignore_parents' do
|
29
|
+
pigheaded :task => 'whatever'
|
30
|
+
end
|
31
|
+
define 'ignore_parents' do
|
32
|
+
wait '1s'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
Bumbleworks.launch!('time_hog')
|
36
|
+
Bumbleworks.dashboard.wait_for(:pigheaded)
|
37
|
+
Bumbleworks.dashboard.processes.count.should == 1
|
38
|
+
expect {
|
39
|
+
described_class.cancel_all_processes!(:timeout => 0.5)
|
40
|
+
}.to raise_error(Bumbleworks::Ruote::CancelTimeout)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
6
44
|
describe '.dashboard' do
|
7
45
|
it 'raises an error if no storage is defined' do
|
8
46
|
Bumbleworks.storage = nil
|
@@ -111,6 +111,11 @@ describe Bumbleworks do
|
|
111
111
|
Bumbleworks::Ruote.should_receive(:start_worker!).and_return(:lets_do_it)
|
112
112
|
Bumbleworks.start_worker!.should == :lets_do_it
|
113
113
|
end
|
114
|
+
|
115
|
+
it 'includes cancel_all_processes!' do
|
116
|
+
Bumbleworks::Ruote.should_receive(:cancel_all_processes!).and_return(:cancelling)
|
117
|
+
Bumbleworks.cancel_all_processes!.should == :cancelling
|
118
|
+
end
|
114
119
|
end
|
115
120
|
|
116
121
|
describe '.launch!' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bumbleworks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-07-
|
15
|
+
date: 2013-07-10 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: ruote
|