ruote 2.1.3 → 2.1.4
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/CHANGELOG.txt +7 -0
- data/Rakefile +1 -1
- data/TODO.txt +2 -0
- data/lib/ruote/context.rb +3 -1
- data/lib/ruote/engine.rb +3 -1
- data/lib/ruote/exp/fe_participant.rb +4 -1
- data/lib/ruote/exp/flowexpression.rb +9 -1
- data/lib/ruote/log/fs_history.rb +4 -5
- data/lib/ruote/log/storage_history.rb +116 -0
- data/lib/ruote/part/storage_participant.rb +24 -1
- data/lib/ruote/storage/base.rb +5 -3
- data/lib/ruote/storage/fs_storage.rb +15 -0
- data/lib/ruote/storage/hash_storage.rb +18 -6
- data/lib/ruote/util/time.rb +1 -1
- data/lib/ruote/worker.rb +2 -4
- data/lib/ruote/workitem.rb +5 -0
- data/ruote.gemspec +8 -6
- data/test/functional/ct_0_concurrence.rb +5 -1
- data/test/functional/ct_1_iterator.rb +1 -1
- data/test/functional/eft_0_process_definition.rb +1 -1
- data/test/functional/eft_10_cancel_process.rb +1 -1
- data/test/functional/eft_13_iterator.rb +1 -1
- data/test/functional/eft_14_cursor.rb +1 -1
- data/test/functional/eft_15_loop.rb +1 -1
- data/test/functional/eft_17_equals.rb +1 -1
- data/test/functional/eft_19_reserve.rb +1 -1
- data/test/functional/eft_1_echo.rb +1 -1
- data/test/functional/eft_20_save.rb +1 -1
- data/test/functional/eft_21_restore.rb +1 -1
- data/test/functional/eft_24_add_branches.rb +1 -1
- data/test/functional/eft_27_inc.rb +1 -1
- data/test/functional/eft_3_participant.rb +1 -1
- data/test/functional/eft_4_set.rb +1 -1
- data/test/functional/eft_5_subprocess.rb +1 -1
- data/test/functional/eft_6_concurrence.rb +1 -1
- data/test/functional/eft_7_forget.rb +1 -1
- data/test/functional/eft_8_undo.rb +1 -1
- data/test/functional/eft_9_redo.rb +1 -1
- data/test/functional/ft_0_worker.rb +1 -1
- data/test/functional/ft_10_dollar.rb +1 -1
- data/test/functional/ft_13_variables.rb +1 -1
- data/test/functional/ft_14_re_apply.rb +1 -1
- data/test/functional/ft_15_timeout.rb +1 -1
- data/test/functional/ft_16_participant_params.rb +1 -1
- data/test/functional/ft_18_kill.rb +1 -1
- data/test/functional/ft_19_alias.rb +1 -1
- data/test/functional/ft_1_process_status.rb +1 -1
- data/test/functional/ft_20_storage_participant.rb +48 -0
- data/test/functional/ft_21_forget.rb +1 -1
- data/test/functional/ft_22_process_definitions.rb +1 -1
- data/test/functional/ft_23_load_defs.rb +1 -1
- data/test/functional/ft_24_block_participants.rb +1 -1
- data/test/functional/ft_2_errors.rb +40 -0
- data/test/functional/{ft_32_history.rb → ft_32_fs_history.rb} +1 -1
- data/test/functional/ft_35_add_service.rb +8 -0
- data/test/functional/ft_36_storage_history.rb +91 -0
- data/test/functional/ft_3_participant_registration.rb +1 -1
- data/test/functional/ft_4_cancel.rb +1 -1
- data/test/functional/ft_5_on_error.rb +1 -1
- data/test/functional/ft_6_on_cancel.rb +1 -1
- data/test/functional/ft_7_tags.rb +1 -1
- data/test/functional/ft_8_participant_consumption.rb +1 -1
- data/test/functional/ft_9_subprocesses.rb +1 -1
- data/test/functional/rt_0_wait.rb +1 -1
- data/test/unit/test.rb +1 -1
- data/test/unit/ut_17_storage.rb +22 -2
- metadata +6 -4
data/CHANGELOG.txt
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
|
2
2
|
= ruote - CHANGELOG.txt
|
3
3
|
|
4
|
+
== ruote - 2.1.4 released 2010/01/11
|
5
|
+
|
6
|
+
- implemented StorageHistory
|
7
|
+
- using yyyy-mm-dd instead of yyyy/mm/dd for Ruote.time_to_utc_s(t)
|
8
|
+
- implemented Storage#purge_type!(t)
|
9
|
+
- Engine#add_service now returning just bound service
|
10
|
+
|
4
11
|
|
5
12
|
== ruote - 2.1.3 released 2010/01/04
|
6
13
|
|
data/Rakefile
CHANGED
@@ -24,7 +24,7 @@ ruote is an open source ruby workflow engine.
|
|
24
24
|
gem.test_file = 'test/test.rb'
|
25
25
|
|
26
26
|
gem.add_dependency 'rufus-json'
|
27
|
-
gem.add_dependency 'rufus-cloche', '>= 0.1.
|
27
|
+
gem.add_dependency 'rufus-cloche', '>= 0.1.13'
|
28
28
|
gem.add_dependency 'rufus-dollar'
|
29
29
|
gem.add_dependency 'rufus-lru'
|
30
30
|
gem.add_dependency 'rufus-mnemo', '>= 1.1.0'
|
data/TODO.txt
CHANGED
@@ -169,6 +169,8 @@
|
|
169
169
|
[o] add_branches : pass message to concurrent_iterator like a command expression
|
170
170
|
[o] clean up persists present in #apply
|
171
171
|
[o] maybe cancel should have a safely / redo_reply thing
|
172
|
+
[o] implement Storage#clear!(type)
|
173
|
+
[o] ruote/util/time.rb utc_to_s 'YYYY/MM/DD' --> 'YYYY-MM-DD' (regex friendly)
|
172
174
|
|
173
175
|
[ ] exp : exp (restricted form of eval ?)
|
174
176
|
[ ] exp : case (is it necessary ?)
|
data/lib/ruote/context.rb
CHANGED
@@ -73,7 +73,7 @@ module Ruote
|
|
73
73
|
|
74
74
|
key = "s_#{key}" unless key.match(/^s\_/)
|
75
75
|
|
76
|
-
if klass
|
76
|
+
service = if klass
|
77
77
|
|
78
78
|
require(path)
|
79
79
|
|
@@ -87,6 +87,8 @@ module Ruote
|
|
87
87
|
end
|
88
88
|
|
89
89
|
self.class.class_eval %{ def #{key[2..-1]}; @conf['#{key}']; end }
|
90
|
+
|
91
|
+
service
|
90
92
|
end
|
91
93
|
|
92
94
|
def shutdown
|
data/lib/ruote/engine.rb
CHANGED
@@ -40,7 +40,7 @@ module Ruote
|
|
40
40
|
|
41
41
|
def initialize (worker_or_storage, run=true)
|
42
42
|
|
43
|
-
if worker_or_storage.respond_to?(:
|
43
|
+
if worker_or_storage.respond_to?(:storage)
|
44
44
|
|
45
45
|
@worker = worker_or_storage
|
46
46
|
@storage = @worker.storage
|
@@ -306,6 +306,8 @@ module Ruote
|
|
306
306
|
#
|
307
307
|
# @engine.add_service('tracer', 'ruote/exp/tracer', 'Ruote::Exp::Tracer')
|
308
308
|
#
|
309
|
+
# This method returns the service instance it just bound.
|
310
|
+
#
|
309
311
|
def add_service (name, path_or_instance, classname=nil, opts=nil)
|
310
312
|
|
311
313
|
@context.add_service(name, path_or_instance, classname, opts)
|
@@ -162,9 +162,12 @@ module Ruote::Exp
|
|
162
162
|
|
163
163
|
def cancel (flavour)
|
164
164
|
|
165
|
+
# TODO : if flavour is 'kill', why not not trigger participant.cancel ?
|
166
|
+
|
165
167
|
participant = @context.plist.lookup(h.participant_name)
|
166
168
|
participant.cancel(fei, flavour)
|
167
|
-
# should this be threaded ?
|
169
|
+
# TODO should this be threaded ?
|
170
|
+
# TODO should errors be intercepted here ?
|
168
171
|
|
169
172
|
reply_to_parent(h.applied_workitem)
|
170
173
|
end
|
@@ -145,7 +145,15 @@ module Ruote::Exp
|
|
145
145
|
|
146
146
|
def self.do_action (context, msg)
|
147
147
|
|
148
|
-
fexp =
|
148
|
+
fexp = nil
|
149
|
+
|
150
|
+
3.times do
|
151
|
+
fexp = fetch(context, msg['fei'])
|
152
|
+
break if fexp
|
153
|
+
sleep 0.028
|
154
|
+
end
|
155
|
+
# this retry system is only useful with ruote-couch
|
156
|
+
|
149
157
|
fexp.send("do_#{msg['action']}", msg) if fexp
|
150
158
|
end
|
151
159
|
|
data/lib/ruote/log/fs_history.rb
CHANGED
@@ -67,9 +67,8 @@ module Ruote
|
|
67
67
|
@file.close rescue nil
|
68
68
|
end
|
69
69
|
|
70
|
-
# Returns
|
71
|
-
#
|
72
|
-
# Returns an empty array if no history was found for the given wfid.
|
70
|
+
# Returns the messages concerning the process given by its wfid,
|
71
|
+
# or an empty array if there were no such process seen.
|
73
72
|
#
|
74
73
|
def by_process (wfid)
|
75
74
|
|
@@ -118,8 +117,8 @@ module Ruote
|
|
118
117
|
end
|
119
118
|
end
|
120
119
|
|
121
|
-
# Returns an array of
|
122
|
-
#
|
120
|
+
# Returns an array of messages for a given day or an empty array if nothing
|
121
|
+
# happened at that date.
|
123
122
|
#
|
124
123
|
def by_date (date)
|
125
124
|
|
@@ -0,0 +1,116 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2005-2010, John Mettraux, jmettraux@gmail.com
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
25
|
+
|
26
|
+
module Ruote
|
27
|
+
|
28
|
+
#
|
29
|
+
# Logs the ruote engine history to the storage underlying the worker.
|
30
|
+
#
|
31
|
+
# Warning : don't use this history implementation when the storage is
|
32
|
+
# HashStorage. It will fill up your memory... Keeping history for a
|
33
|
+
# transient ruote is a bit overkill (IMHO).
|
34
|
+
#
|
35
|
+
class StorageHistory
|
36
|
+
|
37
|
+
def initialize (context, options={})
|
38
|
+
|
39
|
+
@context = context
|
40
|
+
@options = options
|
41
|
+
|
42
|
+
if @context.worker
|
43
|
+
|
44
|
+
# only care about logging if there is a worker present
|
45
|
+
|
46
|
+
@context.storage.add_type('history')
|
47
|
+
@context.worker.subscribe(:all, self)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def by_process (wfid)
|
52
|
+
|
53
|
+
@context.storage.get_many('history', /!#{wfid}$/)
|
54
|
+
end
|
55
|
+
alias :by_wfid :by_process
|
56
|
+
|
57
|
+
# Returns an array [ most recent date, oldest date ] (Time instances).
|
58
|
+
#
|
59
|
+
def range
|
60
|
+
|
61
|
+
ids = @context.storage.ids('history')
|
62
|
+
|
63
|
+
first = Time.parse("#{ids.first.split('!')[0]} 00:00:00 UTC")
|
64
|
+
last = Time.parse("#{ids.last.split('!')[0]} 00:00:00 UTC") + 24 * 3600
|
65
|
+
|
66
|
+
[ first, last ]
|
67
|
+
end
|
68
|
+
|
69
|
+
def by_date (date)
|
70
|
+
|
71
|
+
date = Time.parse(date.to_s).strftime('%F')
|
72
|
+
|
73
|
+
@context.storage.get_many('history', /^#{date}!/)
|
74
|
+
end
|
75
|
+
|
76
|
+
#def history_to_tree (wfid)
|
77
|
+
# # (NOTE why not ?)
|
78
|
+
#end
|
79
|
+
|
80
|
+
# The history system doesn't implement purge! so that when purge! is called
|
81
|
+
# on the engine, the history is not cleared.
|
82
|
+
#
|
83
|
+
# Call this *dangerous* clear! method to clean out any history file.
|
84
|
+
#
|
85
|
+
def clear!
|
86
|
+
|
87
|
+
@context.storage.purge_type!('history')
|
88
|
+
end
|
89
|
+
|
90
|
+
# This is the method called by the workqueue. Incoming engine events
|
91
|
+
# are 'processed' here.
|
92
|
+
#
|
93
|
+
def notify (msg)
|
94
|
+
|
95
|
+
msg = msg.dup
|
96
|
+
# a shallow copy is sufficient
|
97
|
+
|
98
|
+
si = if fei = msg['fei']
|
99
|
+
Ruote::FlowExpressionId.to_storage_id(fei)
|
100
|
+
else
|
101
|
+
msg['wfid'] || 'no_wfid'
|
102
|
+
end
|
103
|
+
|
104
|
+
t = Time.parse(msg['put_at'])
|
105
|
+
|
106
|
+
msg['original_id'] = msg['_id']
|
107
|
+
msg['_id'] = "#{t.strftime('%F')}!#{t.to_i}_#{"%06d" % t.usec}!#{si}"
|
108
|
+
msg['type'] = 'history'
|
109
|
+
msg['original_put_at'] = msg['put_at']
|
110
|
+
msg.delete('_rev')
|
111
|
+
|
112
|
+
@context.storage.put(msg)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
@@ -57,6 +57,7 @@ module Ruote
|
|
57
57
|
|
58
58
|
@context.storage.put(doc)
|
59
59
|
end
|
60
|
+
alias :update :consume
|
60
61
|
|
61
62
|
# Makes sure to remove the workitem from the in-memory hash.
|
62
63
|
#
|
@@ -105,7 +106,14 @@ module Ruote
|
|
105
106
|
#
|
106
107
|
def each (&block)
|
107
108
|
|
108
|
-
|
109
|
+
all.each { |wi| block.call(wi) }
|
110
|
+
end
|
111
|
+
|
112
|
+
# Returns all the workitems stored in here.
|
113
|
+
#
|
114
|
+
def all
|
115
|
+
|
116
|
+
fetch_all.map { |hwi| Ruote::Workitem.new(hwi) }
|
109
117
|
end
|
110
118
|
|
111
119
|
# A convenience method (especially when testing), returns the first
|
@@ -118,7 +126,22 @@ module Ruote
|
|
118
126
|
hwi ? Ruote::Workitem.new(hwi) : nil
|
119
127
|
end
|
120
128
|
|
129
|
+
# Return all workitems for the specified wfid
|
130
|
+
#
|
131
|
+
def by_wfid( wfid )
|
132
|
+
|
133
|
+
@context.storage.get_many('workitems', /!#{wfid}$/).map { |hwi| Ruote::Workitem.new(hwi) }
|
134
|
+
end
|
135
|
+
|
136
|
+
# Return all workitems for the specified participant
|
137
|
+
#
|
138
|
+
def by_participant( part )
|
139
|
+
|
140
|
+
all.select { |wi| wi.participant_name == part }
|
141
|
+
end
|
142
|
+
|
121
143
|
# Clean this participant out completely
|
144
|
+
#
|
122
145
|
def purge!
|
123
146
|
|
124
147
|
fetch_all.each { |hwi| @context.storage.delete( hwi ) }
|
data/lib/ruote/storage/base.rb
CHANGED
@@ -55,17 +55,19 @@ module Ruote
|
|
55
55
|
|
56
56
|
# merge! is way faster than merge (no object creation probably)
|
57
57
|
|
58
|
+
t = Time.now
|
59
|
+
t = "#{t.to_i}.#{"%06d" % t.usec}"
|
60
|
+
|
58
61
|
msg = options.merge!(
|
59
62
|
'type' => 'msgs',
|
60
|
-
'_id' => "#{$$}-#{Thread.current.object_id}-#{
|
63
|
+
'_id' => "#{$$}-#{Thread.current.object_id}-#{t}",
|
61
64
|
'action' => action)
|
62
65
|
|
63
66
|
msg.delete('_rev')
|
64
67
|
# in case of message replay
|
65
68
|
|
66
69
|
put(msg)
|
67
|
-
|
68
|
-
|
70
|
+
#put(msg, :update_rev => true)
|
69
71
|
#(@local_msgs ||= []) << options
|
70
72
|
end
|
71
73
|
|
@@ -72,11 +72,26 @@ module Ruote
|
|
72
72
|
@cloche.get_many(type, key, opts)
|
73
73
|
end
|
74
74
|
|
75
|
+
def ids (type)
|
76
|
+
|
77
|
+
@cloche.ids(type)
|
78
|
+
end
|
79
|
+
|
75
80
|
def purge!
|
76
81
|
|
77
82
|
FileUtils.rm_rf(@cloche.dir)
|
78
83
|
end
|
79
84
|
|
85
|
+
# No need for that here (FsStorage adds type on the fly).
|
86
|
+
#
|
87
|
+
def add_type (type)
|
88
|
+
end
|
89
|
+
|
90
|
+
def purge_type! (type)
|
91
|
+
|
92
|
+
@cloche.purge_type!(type)
|
93
|
+
end
|
94
|
+
|
80
95
|
def dump (type)
|
81
96
|
|
82
97
|
s = "=== #{type} ===\n"
|
@@ -70,7 +70,7 @@ module Ruote
|
|
70
70
|
doc['put_at'] = Ruote.now_to_utc_s
|
71
71
|
doc['_rev'] = doc['_rev'] + 1
|
72
72
|
|
73
|
-
|
73
|
+
@h[doc['type']][doc['_id']] = Rufus::Json.dup(doc)
|
74
74
|
|
75
75
|
nil
|
76
76
|
end
|
@@ -128,6 +128,13 @@ module Ruote
|
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
+
# Returns a sorted list of all the ids for a given type.
|
132
|
+
#
|
133
|
+
def ids (type)
|
134
|
+
|
135
|
+
@h[type].keys.sort
|
136
|
+
end
|
137
|
+
|
131
138
|
def purge!
|
132
139
|
|
133
140
|
@h = %w[
|
@@ -149,6 +156,16 @@ module Ruote
|
|
149
156
|
@h['configurations']['engine'] = @options
|
150
157
|
end
|
151
158
|
|
159
|
+
def add_type (type)
|
160
|
+
|
161
|
+
@h[type] = {}
|
162
|
+
end
|
163
|
+
|
164
|
+
def purge_type! (type)
|
165
|
+
|
166
|
+
@h[type] = {}
|
167
|
+
end
|
168
|
+
|
152
169
|
def dump (type)
|
153
170
|
|
154
171
|
s = "=== #{type} ===\n"
|
@@ -161,11 +178,6 @@ module Ruote
|
|
161
178
|
end
|
162
179
|
end
|
163
180
|
end
|
164
|
-
|
165
|
-
def add_test_type (type)
|
166
|
-
|
167
|
-
@h[type] = {}
|
168
|
-
end
|
169
181
|
end
|
170
182
|
end
|
171
183
|
|
data/lib/ruote/util/time.rb
CHANGED
@@ -47,7 +47,7 @@ module Ruote
|
|
47
47
|
#
|
48
48
|
def self.time_to_utc_s (t)
|
49
49
|
|
50
|
-
"#{t.utc.strftime('%Y
|
50
|
+
"#{t.utc.strftime('%Y-%m-%d %H:%M:%S')}.#{sprintf('%06d', t.usec)} UTC"
|
51
51
|
end
|
52
52
|
|
53
53
|
# Returns a parsable representation of the UTC time now.
|
data/lib/ruote/worker.rb
CHANGED
@@ -27,7 +27,7 @@ require 'ruote/fei'
|
|
27
27
|
|
28
28
|
module Ruote
|
29
29
|
|
30
|
-
VERSION = '2.1.
|
30
|
+
VERSION = '2.1.4'
|
31
31
|
|
32
32
|
class Worker
|
33
33
|
|
@@ -215,8 +215,6 @@ module Ruote
|
|
215
215
|
|
216
216
|
return false unless @storage.reserve(msg)
|
217
217
|
|
218
|
-
fexp = nil
|
219
|
-
|
220
218
|
begin
|
221
219
|
|
222
220
|
action = msg['action']
|
@@ -248,7 +246,7 @@ module Ruote
|
|
248
246
|
|
249
247
|
rescue Exception => ex
|
250
248
|
|
251
|
-
handle_exception(msg,
|
249
|
+
handle_exception(msg, nil, ex)
|
252
250
|
end
|
253
251
|
|
254
252
|
true
|
data/lib/ruote/workitem.rb
CHANGED
data/ruote.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ruote}
|
8
|
-
s.version = "2.1.
|
8
|
+
s.version = "2.1.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["John Mettraux", "Kenneth Kalmer"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-11}
|
13
13
|
s.description = %q{
|
14
14
|
ruote is an open source ruby workflow engine.
|
15
15
|
}
|
@@ -79,6 +79,7 @@ ruote is an open source ruby workflow engine.
|
|
79
79
|
"lib/ruote/id/mnemo_wfid_generator.rb",
|
80
80
|
"lib/ruote/id/wfid_generator.rb",
|
81
81
|
"lib/ruote/log/fs_history.rb",
|
82
|
+
"lib/ruote/log/storage_history.rb",
|
82
83
|
"lib/ruote/log/test_logger.rb",
|
83
84
|
"lib/ruote/log/wait_logger.rb",
|
84
85
|
"lib/ruote/parser.rb",
|
@@ -183,10 +184,11 @@ ruote is an open source ruby workflow engine.
|
|
183
184
|
"test/functional/ft_2_errors.rb",
|
184
185
|
"test/functional/ft_30_smtp_participant.rb",
|
185
186
|
"test/functional/ft_31_part_blocking.rb",
|
186
|
-
"test/functional/
|
187
|
+
"test/functional/ft_32_fs_history.rb",
|
187
188
|
"test/functional/ft_33_participant_subprocess_priority.rb",
|
188
189
|
"test/functional/ft_34_cursor_rewind.rb",
|
189
190
|
"test/functional/ft_35_add_service.rb",
|
191
|
+
"test/functional/ft_36_storage_history.rb",
|
190
192
|
"test/functional/ft_3_participant_registration.rb",
|
191
193
|
"test/functional/ft_4_cancel.rb",
|
192
194
|
"test/functional/ft_5_on_error.rb",
|
@@ -245,7 +247,7 @@ ruote is an open source ruby workflow engine.
|
|
245
247
|
|
246
248
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
247
249
|
s.add_runtime_dependency(%q<rufus-json>, [">= 0"])
|
248
|
-
s.add_runtime_dependency(%q<rufus-cloche>, [">= 0.1.
|
250
|
+
s.add_runtime_dependency(%q<rufus-cloche>, [">= 0.1.13"])
|
249
251
|
s.add_runtime_dependency(%q<rufus-dollar>, [">= 0"])
|
250
252
|
s.add_runtime_dependency(%q<rufus-lru>, [">= 0"])
|
251
253
|
s.add_runtime_dependency(%q<rufus-mnemo>, [">= 1.1.0"])
|
@@ -257,7 +259,7 @@ ruote is an open source ruby workflow engine.
|
|
257
259
|
s.add_development_dependency(%q<mailtrap>, [">= 0"])
|
258
260
|
else
|
259
261
|
s.add_dependency(%q<rufus-json>, [">= 0"])
|
260
|
-
s.add_dependency(%q<rufus-cloche>, [">= 0.1.
|
262
|
+
s.add_dependency(%q<rufus-cloche>, [">= 0.1.13"])
|
261
263
|
s.add_dependency(%q<rufus-dollar>, [">= 0"])
|
262
264
|
s.add_dependency(%q<rufus-lru>, [">= 0"])
|
263
265
|
s.add_dependency(%q<rufus-mnemo>, [">= 1.1.0"])
|
@@ -270,7 +272,7 @@ ruote is an open source ruby workflow engine.
|
|
270
272
|
end
|
271
273
|
else
|
272
274
|
s.add_dependency(%q<rufus-json>, [">= 0"])
|
273
|
-
s.add_dependency(%q<rufus-cloche>, [">= 0.1.
|
275
|
+
s.add_dependency(%q<rufus-cloche>, [">= 0.1.13"])
|
274
276
|
s.add_dependency(%q<rufus-dollar>, [">= 0"])
|
275
277
|
s.add_dependency(%q<rufus-lru>, [">= 0"])
|
276
278
|
s.add_dependency(%q<rufus-mnemo>, [">= 1.1.0"])
|
@@ -27,7 +27,11 @@ class CtConcurrenceTest < Test::Unit::TestCase
|
|
27
27
|
wfid = @engine0.launch(pdef)
|
28
28
|
@engine0.step 4
|
29
29
|
|
30
|
-
|
30
|
+
msgs = @storage.get_msgs
|
31
|
+
$stderr.puts "*cough*" if msgs.size != 2
|
32
|
+
#msgs.each do |m|
|
33
|
+
# p [ m['action'], m['fei']['expid'], m['workitem'] ]
|
34
|
+
#end
|
31
35
|
|
32
36
|
t0 = Thread.new { @engine1.step! }
|
33
37
|
t1 = Thread.new { @engine0.step! }
|
@@ -68,5 +68,53 @@ class FtStorageParticipantTest < Test::Unit::TestCase
|
|
68
68
|
|
69
69
|
assert alpha.first.nil?
|
70
70
|
end
|
71
|
+
|
72
|
+
def test_find_by_wfid
|
73
|
+
|
74
|
+
pdef = Ruote.process_definition :name => 'def0' do
|
75
|
+
concurrence do
|
76
|
+
alpha
|
77
|
+
alpha
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
@engine.register_participant :alpha, Ruote::StorageParticipant
|
82
|
+
|
83
|
+
wfid = @engine.launch(pdef)
|
84
|
+
|
85
|
+
wait_for(:alpha)
|
86
|
+
wait_for(:alpha)
|
87
|
+
# wait for the two workitems
|
88
|
+
|
89
|
+
alpha = Ruote::StorageParticipant.new
|
90
|
+
alpha.context = @engine.context
|
91
|
+
|
92
|
+
assert_equal 2, alpha.size
|
93
|
+
assert_equal 2, alpha.by_wfid(wfid).size
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_find_by_participant
|
97
|
+
|
98
|
+
pdef = Ruote.process_definition :name => 'def0' do
|
99
|
+
concurrence do
|
100
|
+
alpha
|
101
|
+
bravo
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
@engine.register_participant :alpha, Ruote::StorageParticipant
|
106
|
+
@engine.register_participant :bravo, Ruote::StorageParticipant
|
107
|
+
|
108
|
+
wfid = @engine.launch(pdef)
|
109
|
+
|
110
|
+
wait_for(:bravo)
|
111
|
+
|
112
|
+
part = Ruote::StorageParticipant.new
|
113
|
+
part.context = @engine.context
|
114
|
+
|
115
|
+
assert_equal 2, part.size
|
116
|
+
assert_equal 1, part.by_participant('alpha').size
|
117
|
+
assert_equal 1, part.by_participant('bravo').size
|
118
|
+
end
|
71
119
|
end
|
72
120
|
|
@@ -202,6 +202,46 @@ class FtErrorsTest < Test::Unit::TestCase
|
|
202
202
|
assert_equal %w[ alpha alpha done. ].join("\n"), @tracer.to_s
|
203
203
|
end
|
204
204
|
|
205
|
+
class WeakCancelParticipant
|
206
|
+
include Ruote::LocalParticipant
|
207
|
+
|
208
|
+
def initialize (opts)
|
209
|
+
end
|
210
|
+
def consume (workitem)
|
211
|
+
# losing it
|
212
|
+
end
|
213
|
+
def do_not_thread
|
214
|
+
true
|
215
|
+
end
|
216
|
+
def cancel (fei, flavour)
|
217
|
+
raise "failure in #cancel"
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_error_in_participant_cancel
|
222
|
+
|
223
|
+
pdef = Ruote.process_definition do
|
224
|
+
alpha
|
225
|
+
end
|
226
|
+
|
227
|
+
@engine.register_participant 'alpha', WeakCancelParticipant
|
228
|
+
|
229
|
+
noisy
|
230
|
+
|
231
|
+
wfid = @engine.launch(pdef)
|
232
|
+
|
233
|
+
wait_for(:alpha)
|
234
|
+
|
235
|
+
@engine.cancel_process(wfid)
|
236
|
+
|
237
|
+
wait_for(wfid)
|
238
|
+
|
239
|
+
ps = @engine.process(wfid)
|
240
|
+
|
241
|
+
puts ps.errors.first.trace
|
242
|
+
puts ps.expressions.size
|
243
|
+
end
|
244
|
+
|
205
245
|
def test_errors_and_subprocesses
|
206
246
|
|
207
247
|
pdef = Ruote.process_definition do
|
@@ -44,5 +44,13 @@ class FtAddServiceTest < Test::Unit::TestCase
|
|
44
44
|
assert_equal MyService, @engine.context.toto.class
|
45
45
|
assert_equal 'blue', @engine.context.toto.options['colour']
|
46
46
|
end
|
47
|
+
|
48
|
+
def test_add_service_returns_service
|
49
|
+
|
50
|
+
toto = @engine.add_service(
|
51
|
+
'toto', 'ruote', 'FtAddServiceTest::MyService', 'colour' => 'blue')
|
52
|
+
|
53
|
+
assert_equal MyService, toto.class
|
54
|
+
end
|
47
55
|
end
|
48
56
|
|
@@ -0,0 +1,91 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Tue Jan 5 17:51:10 JST 2010
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
require 'ruote/log/fs_history'
|
11
|
+
require 'ruote/part/no_op_participant'
|
12
|
+
|
13
|
+
|
14
|
+
class FtStorageHistoryTest < Test::Unit::TestCase
|
15
|
+
include FunctionalBase
|
16
|
+
|
17
|
+
def test_by_wfid
|
18
|
+
|
19
|
+
pdef = Ruote.process_definition do
|
20
|
+
alpha
|
21
|
+
echo 'done.'
|
22
|
+
end
|
23
|
+
|
24
|
+
history = @engine.add_service(
|
25
|
+
'history', 'ruote/log/storage_history', 'Ruote::StorageHistory')
|
26
|
+
|
27
|
+
@engine.register_participant :alpha, Ruote::NoOpParticipant
|
28
|
+
|
29
|
+
#noisy
|
30
|
+
|
31
|
+
wfid0 = assert_trace(pdef, "done.")
|
32
|
+
wfid1 = assert_trace(pdef, "done.\ndone.")
|
33
|
+
|
34
|
+
sleep 0.100
|
35
|
+
|
36
|
+
assert_equal 17, @engine.storage.get_many('history').size
|
37
|
+
|
38
|
+
h = @engine.context.history.by_process(wfid0)
|
39
|
+
#h.each { |r| p r }
|
40
|
+
assert_equal 8, h.size
|
41
|
+
|
42
|
+
# testing record.to_h
|
43
|
+
|
44
|
+
h = @engine.context.history.by_process(wfid1)
|
45
|
+
#h.each { |r| p r }
|
46
|
+
assert_equal 8, h.size
|
47
|
+
|
48
|
+
history.clear!
|
49
|
+
|
50
|
+
assert_equal 0, @engine.storage.get_many('history').size
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_by_date
|
54
|
+
|
55
|
+
@engine.add_service(
|
56
|
+
'history', 'ruote/log/storage_history', 'Ruote::StorageHistory')
|
57
|
+
|
58
|
+
6.times do |i|
|
59
|
+
@engine.storage.put(
|
60
|
+
'_id' => "2010-01-06!11414#{i}!0!!20100106-bichisosupo",
|
61
|
+
'type' => 'history')
|
62
|
+
end
|
63
|
+
7.times do |i|
|
64
|
+
@engine.storage.put(
|
65
|
+
'_id' => "2010-01-07!11414#{i}!0!!20100107-bichitehoni",
|
66
|
+
'type' => 'history')
|
67
|
+
end
|
68
|
+
|
69
|
+
assert_equal 6, @engine.context.history.by_date('2010-01-06').size
|
70
|
+
assert_equal 7, @engine.context.history.by_date('2010-01-07').size
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_range
|
74
|
+
|
75
|
+
@engine.add_service(
|
76
|
+
'history', 'ruote/log/storage_history', 'Ruote::StorageHistory')
|
77
|
+
|
78
|
+
7.times do |i|
|
79
|
+
i = i + 1
|
80
|
+
@engine.storage.put(
|
81
|
+
'_id' => "2010-01-0#{i}!114147!0!!2010010#{i}-bichisosupo",
|
82
|
+
'type' => 'history')
|
83
|
+
end
|
84
|
+
|
85
|
+
assert_equal(
|
86
|
+
[ Time.parse('2010-01-01 00:00:00 UTC'),
|
87
|
+
Time.parse('2010-01-08 00:00:00 UTC') ],
|
88
|
+
@engine.context.history.range)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
data/test/unit/test.rb
CHANGED
data/test/unit/ut_17_storage.rb
CHANGED
@@ -10,7 +10,11 @@ begin
|
|
10
10
|
rescue LoadError
|
11
11
|
require 'json'
|
12
12
|
end
|
13
|
-
|
13
|
+
begin
|
14
|
+
require 'patron'
|
15
|
+
rescue LoadError
|
16
|
+
# stick with net/http
|
17
|
+
end
|
14
18
|
|
15
19
|
require File.join(File.dirname(__FILE__), %w[ .. test_helper.rb ])
|
16
20
|
require File.join(File.dirname(__FILE__), %w[ .. functional storage_helper.rb ])
|
@@ -20,7 +24,7 @@ class UtStorage < Test::Unit::TestCase
|
|
20
24
|
|
21
25
|
def setup
|
22
26
|
@s = determine_storage({})
|
23
|
-
@s.
|
27
|
+
@s.add_type('dogfood')
|
24
28
|
@s.put(
|
25
29
|
'_id' => 'toto',
|
26
30
|
'type' => 'dogfood',
|
@@ -130,5 +134,21 @@ class UtStorage < Test::Unit::TestCase
|
|
130
134
|
|
131
135
|
assert_equal true, @s.put(h)
|
132
136
|
end
|
137
|
+
|
138
|
+
def test_purge_type
|
139
|
+
|
140
|
+
@s.purge_type!('dogfood')
|
141
|
+
|
142
|
+
assert_equal 0, @s.get_many('dogfood').size
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_ids
|
146
|
+
|
147
|
+
@s.put('_id' => 'ouinouin', 'type' => 'dogfood', 'message' => 'testing')
|
148
|
+
@s.put('_id' => 'nada', 'type' => 'dogfood', 'message' => 'testing')
|
149
|
+
@s.put('_id' => 'estereo', 'type' => 'dogfood', 'message' => 'testing')
|
150
|
+
|
151
|
+
assert_equal %w[ estereo nada ouinouin toto ], @s.ids('dogfood')
|
152
|
+
end
|
133
153
|
end
|
134
154
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mettraux
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2010-01-
|
13
|
+
date: 2010-01-11 00:00:00 +09:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 0.1.
|
34
|
+
version: 0.1.13
|
35
35
|
version:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rufus-dollar
|
@@ -194,6 +194,7 @@ files:
|
|
194
194
|
- lib/ruote/id/mnemo_wfid_generator.rb
|
195
195
|
- lib/ruote/id/wfid_generator.rb
|
196
196
|
- lib/ruote/log/fs_history.rb
|
197
|
+
- lib/ruote/log/storage_history.rb
|
197
198
|
- lib/ruote/log/test_logger.rb
|
198
199
|
- lib/ruote/log/wait_logger.rb
|
199
200
|
- lib/ruote/parser.rb
|
@@ -298,10 +299,11 @@ files:
|
|
298
299
|
- test/functional/ft_2_errors.rb
|
299
300
|
- test/functional/ft_30_smtp_participant.rb
|
300
301
|
- test/functional/ft_31_part_blocking.rb
|
301
|
-
- test/functional/
|
302
|
+
- test/functional/ft_32_fs_history.rb
|
302
303
|
- test/functional/ft_33_participant_subprocess_priority.rb
|
303
304
|
- test/functional/ft_34_cursor_rewind.rb
|
304
305
|
- test/functional/ft_35_add_service.rb
|
306
|
+
- test/functional/ft_36_storage_history.rb
|
305
307
|
- test/functional/ft_3_participant_registration.rb
|
306
308
|
- test/functional/ft_4_cancel.rb
|
307
309
|
- test/functional/ft_5_on_error.rb
|