ruote 2.1.11 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +60 -0
- data/CREDITS.txt +22 -4
- data/LICENSE.txt +1 -1
- data/README.rdoc +6 -7
- data/Rakefile +58 -59
- data/TODO.txt +137 -65
- data/couch_url.txt +1 -0
- data/jruby_issue.txt +32 -0
- data/lib/ruote.rb +1 -1
- data/lib/ruote/context.rb +12 -10
- data/lib/ruote/engine.rb +280 -145
- data/lib/ruote/engine/process_error.rb +5 -5
- data/lib/ruote/engine/process_status.rb +47 -28
- data/lib/ruote/exp/command.rb +7 -10
- data/lib/ruote/exp/commanded.rb +2 -2
- data/lib/ruote/exp/condition.rb +130 -43
- data/lib/ruote/exp/fe_add_branches.rb +2 -2
- data/lib/ruote/exp/fe_apply.rb +1 -1
- data/lib/ruote/exp/fe_cancel_process.rb +3 -3
- data/lib/ruote/exp/fe_command.rb +3 -3
- data/lib/ruote/exp/fe_concurrence.rb +4 -4
- data/lib/ruote/exp/fe_concurrent_iterator.rb +17 -5
- data/lib/ruote/exp/fe_cron.rb +3 -3
- data/lib/ruote/exp/fe_cursor.rb +5 -5
- data/lib/ruote/exp/fe_define.rb +3 -3
- data/lib/ruote/exp/fe_echo.rb +3 -3
- data/lib/ruote/exp/fe_equals.rb +2 -2
- data/lib/ruote/exp/fe_error.rb +2 -2
- data/lib/ruote/exp/fe_filter.rb +519 -0
- data/lib/ruote/exp/fe_forget.rb +9 -2
- data/lib/ruote/exp/fe_given.rb +154 -0
- data/lib/ruote/exp/fe_if.rb +16 -13
- data/lib/ruote/exp/fe_inc.rb +3 -3
- data/lib/ruote/exp/fe_iterator.rb +4 -4
- data/lib/ruote/exp/fe_let.rb +75 -0
- data/lib/ruote/exp/fe_listen.rb +68 -12
- data/lib/ruote/exp/fe_lose.rb +110 -0
- data/lib/ruote/exp/fe_noop.rb +1 -1
- data/lib/ruote/exp/{fe_when.rb → fe_once.rb} +25 -21
- data/lib/ruote/exp/fe_participant.rb +14 -17
- data/lib/ruote/exp/fe_redo.rb +10 -6
- data/lib/ruote/exp/fe_ref.rb +1 -1
- data/lib/ruote/exp/fe_registerp.rb +112 -0
- data/lib/ruote/exp/fe_reserve.rb +3 -3
- data/lib/ruote/exp/fe_restore.rb +2 -2
- data/lib/ruote/exp/fe_save.rb +2 -2
- data/lib/ruote/exp/fe_sequence.rb +3 -4
- data/lib/ruote/exp/fe_set.rb +16 -7
- data/lib/ruote/exp/fe_subprocess.rb +23 -1
- data/lib/ruote/exp/fe_that.rb +92 -0
- data/lib/ruote/exp/fe_undo.rb +3 -3
- data/lib/ruote/exp/fe_unregisterp.rb +71 -0
- data/lib/ruote/exp/fe_wait.rb +2 -2
- data/lib/ruote/exp/flowexpression.rb +153 -78
- data/lib/ruote/exp/iterator.rb +2 -2
- data/lib/ruote/exp/merge.rb +2 -2
- data/lib/ruote/exp/ro_attributes.rb +14 -12
- data/lib/ruote/exp/ro_filters.rb +136 -0
- data/lib/ruote/exp/ro_persist.rb +51 -35
- data/lib/ruote/exp/ro_variables.rb +18 -27
- data/lib/ruote/fei.rb +73 -33
- data/lib/ruote/id/mnemo_wfid_generator.rb +1 -1
- data/lib/ruote/id/wfid_generator.rb +11 -4
- data/lib/ruote/log/default_history.rb +122 -0
- data/lib/ruote/log/pretty.rb +36 -8
- data/lib/ruote/log/storage_history.rb +37 -5
- data/lib/ruote/log/test_logger.rb +26 -24
- data/lib/ruote/log/wait_logger.rb +5 -3
- data/lib/ruote/part/block_participant.rb +22 -11
- data/lib/ruote/part/engine_participant.rb +6 -7
- data/lib/ruote/part/local_participant.rb +6 -12
- data/lib/ruote/part/no_op_participant.rb +4 -4
- data/lib/ruote/part/null_participant.rb +4 -4
- data/lib/ruote/part/smtp_participant.rb +4 -4
- data/lib/ruote/part/storage_participant.rb +40 -20
- data/lib/ruote/part/template.rb +4 -4
- data/lib/ruote/participant.rb +0 -1
- data/lib/ruote/{parser.rb → reader.rb} +30 -25
- data/lib/ruote/{parser → reader}/ruby_dsl.rb +28 -11
- data/lib/ruote/{parser → reader}/xml.rb +6 -5
- data/lib/ruote/receiver/base.rb +35 -13
- data/lib/ruote/storage/base.rb +20 -18
- data/lib/ruote/storage/composite_storage.rb +10 -10
- data/lib/ruote/storage/fs_storage.rb +17 -10
- data/lib/ruote/storage/hash_storage.rb +29 -18
- data/lib/ruote/svc/dispatch_pool.rb +41 -14
- data/lib/ruote/svc/dollar_sub.rb +50 -17
- data/lib/ruote/svc/error_handler.rb +19 -11
- data/lib/ruote/svc/expression_map.rb +4 -4
- data/lib/ruote/svc/participant_list.rb +105 -100
- data/lib/ruote/svc/tracker.rb +58 -18
- data/lib/ruote/svc/treechecker.rb +51 -24
- data/lib/ruote/tree_dot.rb +4 -4
- data/lib/ruote/util/filter.rb +440 -0
- data/lib/ruote/util/hashdot.rb +4 -4
- data/lib/ruote/util/look.rb +2 -6
- data/lib/ruote/util/lookup.rb +9 -7
- data/lib/ruote/util/misc.rb +40 -8
- data/lib/ruote/util/ometa.rb +1 -1
- data/lib/ruote/util/serializer.rb +4 -4
- data/lib/ruote/util/subprocess.rb +29 -9
- data/lib/ruote/util/time.rb +4 -4
- data/lib/ruote/util/tree.rb +3 -3
- data/lib/ruote/version.rb +2 -2
- data/lib/ruote/worker.rb +55 -32
- data/lib/ruote/workitem.rb +64 -11
- data/ruote.gemspec +31 -302
- data/test/bm/launch_bench.rb +37 -0
- data/test/functional/base.rb +60 -18
- data/test/functional/concurrent_base.rb +2 -2
- data/test/functional/ct_0_concurrence.rb +1 -1
- data/test/functional/ct_1_iterator.rb +1 -1
- data/test/functional/ct_2_cancel.rb +1 -1
- data/test/functional/eft_0_process_definition.rb +2 -2
- data/test/functional/eft_10_cancel_process.rb +1 -1
- data/test/functional/eft_11_wait.rb +19 -11
- data/test/functional/eft_12_listen.rb +79 -13
- data/test/functional/eft_13_iterator.rb +13 -10
- data/test/functional/eft_14_cursor.rb +98 -9
- data/test/functional/eft_15_loop.rb +6 -4
- data/test/functional/eft_16_if.rb +12 -0
- data/test/functional/eft_18_concurrent_iterator.rb +31 -32
- data/test/functional/eft_19_reserve.rb +4 -4
- data/test/functional/eft_1_echo.rb +9 -0
- data/test/functional/eft_20_save.rb +4 -4
- data/test/functional/{eft_28_when.rb → eft_28_once.rb} +33 -7
- data/test/functional/eft_30_ref.rb +17 -2
- data/test/functional/eft_31_registerp.rb +130 -0
- data/test/functional/eft_32_lose.rb +93 -0
- data/test/functional/eft_33_let.rb +31 -0
- data/test/functional/eft_34_given.rb +123 -0
- data/test/functional/eft_35_filter.rb +269 -0
- data/test/functional/eft_3_participant.rb +4 -6
- data/test/functional/eft_4_set.rb +16 -2
- data/test/functional/eft_5_subprocess.rb +2 -4
- data/test/functional/eft_6_concurrence.rb +29 -29
- data/test/functional/eft_8_undo.rb +39 -3
- data/test/functional/eft_9_redo.rb +94 -2
- data/test/functional/ft_10_dollar.rb +81 -2
- data/test/functional/ft_11_recursion.rb +13 -17
- data/test/functional/ft_12_launchitem.rb +9 -5
- data/test/functional/ft_13_variables.rb +7 -9
- data/test/functional/ft_14_re_apply.rb +6 -9
- data/test/functional/ft_15_timeout.rb +18 -18
- data/test/functional/ft_16_participant_params.rb +1 -3
- data/test/functional/ft_17_conditional.rb +25 -2
- data/test/functional/ft_18_kill.rb +65 -12
- data/test/functional/ft_1_process_status.rb +147 -71
- data/test/functional/ft_20_storage_participant.rb +0 -1
- data/test/functional/ft_21_forget.rb +82 -1
- data/test/functional/{ft_24_block_participants.rb → ft_24_block_participant.rb} +42 -11
- data/test/functional/ft_25_receiver.rb +47 -17
- data/test/functional/{ft_26_participant_timeout.rb → ft_26_participant_rtimeout.rb} +56 -19
- data/test/functional/ft_29_part_template.rb +6 -5
- data/test/functional/ft_2_errors.rb +21 -37
- data/test/functional/ft_30_smtp_participant.rb +1 -1
- data/test/functional/ft_31_part_blocking.rb +8 -6
- data/test/functional/ft_34_cursor_rewind.rb +13 -10
- data/test/functional/ft_35_add_service.rb +1 -1
- data/test/functional/ft_36_storage_history.rb +24 -1
- data/test/functional/ft_37_default_history.rb +109 -0
- data/test/functional/ft_38_participant_more.rb +10 -10
- data/test/functional/ft_39_wait_for.rb +12 -9
- data/test/functional/ft_3_participant_registration.rb +111 -32
- data/test/functional/ft_40_wait_logger.rb +2 -1
- data/test/functional/ft_41_participants.rb +30 -4
- data/test/functional/ft_43_participant_on_reply.rb +6 -23
- data/test/functional/ft_45_participant_accept.rb +4 -4
- data/test/functional/ft_46_launch_single.rb +36 -2
- data/test/functional/ft_47_wfid_generator.rb +54 -0
- data/test/functional/ft_48_lose.rb +112 -0
- data/test/functional/ft_49_engine_on_error.rb +201 -0
- data/test/functional/ft_4_cancel.rb +66 -6
- data/test/functional/ft_50_engine_config.rb +22 -0
- data/test/functional/ft_51_misc.rb +67 -0
- data/test/functional/ft_52_case.rb +134 -0
- data/test/functional/ft_53_engine_on_terminate.rb +95 -0
- data/test/functional/ft_54_patterns.rb +104 -0
- data/test/functional/{ft_37_engine_participant.rb → ft_55_engine_participant.rb} +4 -5
- data/test/functional/ft_56_filter_attribute.rb +259 -0
- data/test/functional/ft_5_on_error.rb +77 -30
- data/test/functional/ft_6_on_cancel.rb +66 -11
- data/test/functional/ft_7_tags.rb +94 -5
- data/test/functional/ft_8_participant_consumption.rb +36 -5
- data/test/functional/ft_9_subprocesses.rb +10 -10
- data/test/functional/rt_1_listen.rb +3 -3
- data/test/functional/{rt_3_when.rb → rt_3_once.rb} +4 -4
- data/test/functional/storage_helper.rb +15 -13
- data/test/functional/test.rb +1 -3
- data/test/test_helper.rb +0 -8
- data/test/unit/storage.rb +154 -10
- data/test/unit/{ut_0_ruby_parser.rb → ut_0_ruby_reader.rb} +61 -11
- data/test/unit/ut_11_lookup.rb +7 -0
- data/test/unit/ut_13_serializer.rb +1 -1
- data/test/unit/ut_15_util.rb +23 -0
- data/test/unit/{ut_16_parser.rb → ut_16_reader.rb} +11 -13
- data/test/unit/ut_1_fei.rb +57 -10
- data/test/unit/ut_20_composite_storage.rb +25 -11
- data/test/unit/ut_21_participant_list.rb +47 -0
- data/test/unit/ut_22_filter.rb +903 -0
- data/test/unit/ut_3_wait_logger.rb +2 -6
- data/test/unit/ut_6_condition.rb +164 -17
- data/test/unit/ut_7_workitem.rb +28 -0
- data/test/unit/ut_8_tree_to_dot.rb +1 -1
- data/test/unit/{ut_9_xml_parser.rb → ut_9_xml_reader.rb} +5 -5
- metadata +108 -84
- data/.gitignore +0 -4
- data/examples/barley.rb +0 -391
- data/examples/flickr_report.rb +0 -107
- data/examples/pong.rb +0 -37
- data/examples/ruote_quickstart.rb +0 -43
- data/examples/web_first_page.rb +0 -68
- data/lib/ruote/part/hash_participant.rb +0 -91
- data/test/README.rdoc +0 -15
- data/test/functional/crunner.sh +0 -19
- data/test/pdef.xml +0 -7
- data/test/unit/ut_2_wfidgen.rb +0 -21
@@ -0,0 +1,110 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2005-2011, 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::Exp
|
27
|
+
|
28
|
+
#
|
29
|
+
# Never replies to its parent expression. Simply applies its first child,
|
30
|
+
# if any, and just sits there.
|
31
|
+
#
|
32
|
+
# When cancelled, cancels its child (if any).
|
33
|
+
#
|
34
|
+
# In this example, the reminding sequence never replies to the concurrence.
|
35
|
+
# The concurrence is only over when "alfred" replies.
|
36
|
+
#
|
37
|
+
# Ruote.process_definition do
|
38
|
+
# concurrence :count => 1 do
|
39
|
+
# alfred
|
40
|
+
# lose do
|
41
|
+
# sequence do
|
42
|
+
# wait '2d'
|
43
|
+
# send_reminder_to_alfred
|
44
|
+
# wait '2h'
|
45
|
+
# send_alarm_to_boss
|
46
|
+
# end
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# Maybe shorter :
|
52
|
+
#
|
53
|
+
# Ruote.process_definition do
|
54
|
+
# concurrence :count => 1 do
|
55
|
+
# alfred
|
56
|
+
# sequence do
|
57
|
+
# wait '2d'
|
58
|
+
# send_reminder_to_alfred
|
59
|
+
# wait '2h'
|
60
|
+
# send_alarm_to_boss
|
61
|
+
# lose
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
# end
|
65
|
+
#
|
66
|
+
# 'lose' on its own acts like a dead-end.
|
67
|
+
#
|
68
|
+
#
|
69
|
+
# == the :lose attribute
|
70
|
+
#
|
71
|
+
# Every expression understands the 'lose' attribute :
|
72
|
+
#
|
73
|
+
# Ruote.process_definition do
|
74
|
+
# concurrence :count => 1 do
|
75
|
+
# alfred
|
76
|
+
# sequence :lose => true do
|
77
|
+
# wait '2d'
|
78
|
+
# send_reminder_to_alfred
|
79
|
+
# wait '2h'
|
80
|
+
# send_alarm_to_boss
|
81
|
+
# end
|
82
|
+
# end
|
83
|
+
# end
|
84
|
+
#
|
85
|
+
# Probably produces definitions more compact than when using the 'lose'
|
86
|
+
# expression.
|
87
|
+
#
|
88
|
+
# == forget vs lose
|
89
|
+
#
|
90
|
+
# forget : replies to parent expression immediately, is not cancellable
|
91
|
+
# (not reachable).
|
92
|
+
#
|
93
|
+
# lose : never replies to parent expression, is cancellable.
|
94
|
+
#
|
95
|
+
class LoseExpression < FlowExpression
|
96
|
+
|
97
|
+
names :lose
|
98
|
+
|
99
|
+
def apply
|
100
|
+
|
101
|
+
apply_child(0, h.applied_workitem)
|
102
|
+
end
|
103
|
+
|
104
|
+
def reply(workitem)
|
105
|
+
|
106
|
+
# never gets called
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
data/lib/ruote/exp/fe_noop.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -26,14 +26,14 @@
|
|
26
26
|
module Ruote::Exp
|
27
27
|
|
28
28
|
#
|
29
|
-
# The 'when' expression verifies if a condition is true,
|
30
|
-
# block and after 10 seconds it will check again.
|
29
|
+
# The 'once' / 'when' expression verifies if a condition is true,
|
30
|
+
# if not it will block and after 10 seconds it will check again.
|
31
31
|
# If true, it will resume or it will execute its child expression (before
|
32
32
|
# resuming).
|
33
33
|
#
|
34
34
|
# concurrence do
|
35
35
|
#
|
36
|
-
#
|
36
|
+
# once '${v:/invoice_status} == emitted' do
|
37
37
|
# open_customer_support_account
|
38
38
|
# end
|
39
39
|
#
|
@@ -44,8 +44,6 @@ module Ruote::Exp
|
|
44
44
|
# end
|
45
45
|
# end
|
46
46
|
#
|
47
|
-
# Note the '_when' since 'when' is a Ruby keyword :-(
|
48
|
-
#
|
49
47
|
# The condition is usually something about variables, since the workitem that
|
50
48
|
# this expression has access to is always the one that reached it, at apply
|
51
49
|
# time.
|
@@ -55,7 +53,7 @@ module Ruote::Exp
|
|
55
53
|
#
|
56
54
|
# sequence do
|
57
55
|
# first_stage
|
58
|
-
#
|
56
|
+
# once '${v:ready_for_second_stage}'
|
59
57
|
# second_stage
|
60
58
|
# end
|
61
59
|
#
|
@@ -64,7 +62,7 @@ module Ruote::Exp
|
|
64
62
|
# 'sequence'.
|
65
63
|
#
|
66
64
|
# concurrence do
|
67
|
-
#
|
65
|
+
# once :test => '${v:go_on} == yes' do
|
68
66
|
# subprocess :ref => 'final_stage'
|
69
67
|
# end
|
70
68
|
# sequence do
|
@@ -80,13 +78,13 @@ module Ruote::Exp
|
|
80
78
|
# if you prefer it this way, you can use the :test attribute to formulate the
|
81
79
|
# condition :
|
82
80
|
#
|
83
|
-
# <
|
81
|
+
# <once test="${v:ready}">
|
84
82
|
# <participant ref="role_publisher" />
|
85
|
-
# </
|
83
|
+
# </once>
|
86
84
|
#
|
87
85
|
# In a Ruby process definition :
|
88
86
|
#
|
89
|
-
#
|
87
|
+
# once :test => '${v:ready}' do
|
90
88
|
# participant :ref => 'role_publisher'
|
91
89
|
# end
|
92
90
|
#
|
@@ -98,7 +96,7 @@ module Ruote::Exp
|
|
98
96
|
#
|
99
97
|
# sequence do
|
100
98
|
# participant 'logistic_unit'
|
101
|
-
#
|
99
|
+
# once '${v:/delivery_ok}', :frequency => '2d'
|
102
100
|
# # block until delivery is OK (another branch of the process probably)
|
103
101
|
# # check every two days
|
104
102
|
# participant 'accounting_unit'
|
@@ -109,8 +107,8 @@ module Ruote::Exp
|
|
109
107
|
#
|
110
108
|
# It's OK to pass a 'cron string' to the :frequency attribute.
|
111
109
|
#
|
112
|
-
#
|
113
|
-
# # this '
|
110
|
+
# once '${v:delivery_complete}', :freq => '5 0 * * *'
|
111
|
+
# # this 'once' will check its condition once per day, five minutes
|
114
112
|
# # after midnight
|
115
113
|
#
|
116
114
|
# See "man 5 crontab" on your favourite unix system for the details of
|
@@ -124,7 +122,7 @@ module Ruote::Exp
|
|
124
122
|
# Don't forget that this expression, like all the other expressions accepts
|
125
123
|
# the :timeout attribute. It's perhaps better to use :timeout when there is
|
126
124
|
# a child expression, so that the child won't get 'triggered' in case of
|
127
|
-
# timeout. When there is no child expression and the '
|
125
|
+
# timeout. When there is no child expression and the 'once' behaves in a
|
128
126
|
# 'blocking way', a timeout will unblock, as if the condition became true.
|
129
127
|
#
|
130
128
|
#
|
@@ -133,13 +131,19 @@ module Ruote::Exp
|
|
133
131
|
# Remember that, if the engine's 'ruby_eval_allowed' is set to true, the
|
134
132
|
# condition may contain Ruby code.
|
135
133
|
#
|
136
|
-
#
|
134
|
+
# once '${r:"hell" + "o"} == hello'
|
137
135
|
#
|
138
136
|
# This Ruby code is checked before hand against malicious code, but beware...
|
139
137
|
#
|
140
|
-
|
138
|
+
#
|
139
|
+
# == aliases
|
140
|
+
#
|
141
|
+
# 'once', '_when' and 'as_soon_as' are three different names for this
|
142
|
+
# expression.
|
143
|
+
#
|
144
|
+
class OnceExpression < FlowExpression
|
141
145
|
|
142
|
-
names :when, :as_soon_as
|
146
|
+
names :once, :when, :as_soon_as
|
143
147
|
|
144
148
|
def apply
|
145
149
|
|
@@ -150,7 +154,7 @@ module Ruote::Exp
|
|
150
154
|
reply(h.applied_workitem)
|
151
155
|
end
|
152
156
|
|
153
|
-
def reply
|
157
|
+
def reply(workitem)
|
154
158
|
|
155
159
|
return reply_to_parent(workitem) if h.triggered
|
156
160
|
|
@@ -180,10 +184,10 @@ module Ruote::Exp
|
|
180
184
|
end
|
181
185
|
end
|
182
186
|
|
183
|
-
def cancel
|
187
|
+
def cancel(flavour)
|
184
188
|
|
185
189
|
@context.storage.delete_schedule(h.job_id)
|
186
|
-
|
190
|
+
super
|
187
191
|
end
|
188
192
|
|
189
193
|
protected
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -91,7 +91,8 @@ module Ruote::Exp
|
|
91
91
|
#
|
92
92
|
# But it's OK for participant classes registered in the engine to provide
|
93
93
|
# their own timeout value. The participant instance simply has to reply to
|
94
|
-
# the #
|
94
|
+
# the #rtimeout method and provide a meaningful timeout value (like a
|
95
|
+
# number of seconds, or a string like "2d" or "1M2w".
|
95
96
|
#
|
96
97
|
# Note however, that the process definition timeout (if any) will take
|
97
98
|
# precedence over the participant specified one.
|
@@ -114,9 +115,6 @@ module Ruote::Exp
|
|
114
115
|
#
|
115
116
|
class ParticipantExpression < FlowExpression
|
116
117
|
|
117
|
-
#include FilterMixin
|
118
|
-
# TODO
|
119
|
-
|
120
118
|
names :participant
|
121
119
|
|
122
120
|
# Should return true when the dispatch was successful.
|
@@ -166,11 +164,10 @@ module Ruote::Exp
|
|
166
164
|
'fei' => h.fei,
|
167
165
|
'participant_name' => h.participant_name,
|
168
166
|
'participant' => h.participant,
|
169
|
-
'workitem' => h.applied_workitem
|
170
|
-
'for_engine_worker?' => (participant_info.class != Array))
|
167
|
+
'workitem' => h.applied_workitem)
|
171
168
|
end
|
172
169
|
|
173
|
-
def cancel
|
170
|
+
def cancel(flavour)
|
174
171
|
|
175
172
|
return reply_to_parent(h.applied_workitem) unless h.participant_name
|
176
173
|
# no participant, reply immediately
|
@@ -189,7 +186,7 @@ module Ruote::Exp
|
|
189
186
|
'workitem' => h.applied_workitem)
|
190
187
|
end
|
191
188
|
|
192
|
-
def reply
|
189
|
+
def reply(workitem)
|
193
190
|
|
194
191
|
pinfo =
|
195
192
|
h.participant ||
|
@@ -202,7 +199,7 @@ module Ruote::Exp
|
|
202
199
|
super(workitem)
|
203
200
|
end
|
204
201
|
|
205
|
-
def reply_to_parent
|
202
|
+
def reply_to_parent(workitem)
|
206
203
|
|
207
204
|
workitem['fields'].delete('params')
|
208
205
|
workitem['fields'].delete('dispatched_at')
|
@@ -218,7 +215,7 @@ module Ruote::Exp
|
|
218
215
|
# See http://groups.google.com/group/openwferu-users/browse_thread/thread/ff29f26d6b5fd135
|
219
216
|
# for the motivation.
|
220
217
|
#
|
221
|
-
def do_dispatched
|
218
|
+
def do_dispatched(msg)
|
222
219
|
|
223
220
|
h.dispatched = true
|
224
221
|
do_persist
|
@@ -236,18 +233,18 @@ module Ruote::Exp
|
|
236
233
|
# Note that process definition timeout has priority over participant
|
237
234
|
# specified timeout.
|
238
235
|
#
|
239
|
-
def schedule_timeout
|
236
|
+
def schedule_timeout(p_info)
|
240
237
|
|
241
238
|
timeout = attribute(:timeout)
|
242
239
|
|
243
240
|
unless timeout
|
244
241
|
|
245
|
-
pa = @context.plist.instantiate(p_info, :if_respond_to? => :
|
242
|
+
pa = @context.plist.instantiate(p_info, :if_respond_to? => :rtimeout)
|
246
243
|
|
247
|
-
timeout = pa.
|
248
|
-
|
249
|
-
|
250
|
-
|
244
|
+
timeout = (pa.method(:rtimeout).arity == 0 ?
|
245
|
+
pa.rtimeout :
|
246
|
+
pa.rtimeout(Ruote::Workitem.new(h.applied_workitem))
|
247
|
+
) if pa
|
251
248
|
end
|
252
249
|
|
253
250
|
do_schedule_timeout(timeout)
|
data/lib/ruote/exp/fe_redo.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -29,8 +29,8 @@ module Ruote::Exp
|
|
29
29
|
# Undoes and the redoes (re-applies) an expression identified by a tag.
|
30
30
|
#
|
31
31
|
# pdef = Ruote.process_definition do
|
32
|
-
# sequence do
|
33
|
-
# alpha
|
32
|
+
# sequence :tag => 'kilroy' do
|
33
|
+
# alpha
|
34
34
|
# _redo :ref => 'kilroy', :unless => '${f:ok} == true'
|
35
35
|
# end
|
36
36
|
# end
|
@@ -43,11 +43,15 @@ module Ruote::Exp
|
|
43
43
|
#
|
44
44
|
# pdef = Ruote.process_definition do
|
45
45
|
# cursor do
|
46
|
-
# alpha
|
46
|
+
# alpha
|
47
47
|
# rewind :unless => '${f:ok} == true'
|
48
48
|
# end
|
49
49
|
# end
|
50
50
|
#
|
51
|
+
# (There is a big difference though, a redo will restart with the workitem
|
52
|
+
# as it was when the workitem entered the tagged region, while the rewind
|
53
|
+
# keeps the workitem as is)
|
54
|
+
#
|
51
55
|
class RedoExpression < FlowExpression
|
52
56
|
|
53
57
|
names :redo
|
@@ -57,7 +61,7 @@ module Ruote::Exp
|
|
57
61
|
ref = attribute(:ref) || attribute_text
|
58
62
|
tag = ref ? lookup_variable(ref) : nil
|
59
63
|
|
60
|
-
if tag
|
64
|
+
if tag && Ruote.is_a_fei?(tag)
|
61
65
|
|
62
66
|
@context.storage.put_msg('cancel', 'fei' => tag, 're_apply' => true)
|
63
67
|
|
@@ -69,7 +73,7 @@ module Ruote::Exp
|
|
69
73
|
end
|
70
74
|
end
|
71
75
|
|
72
|
-
def reply
|
76
|
+
def reply(workitem)
|
73
77
|
|
74
78
|
# never called
|
75
79
|
end
|
data/lib/ruote/exp/fe_ref.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -0,0 +1,112 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2005-2011, 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::Exp
|
27
|
+
|
28
|
+
#
|
29
|
+
# (Since ruote 2.1.12)
|
30
|
+
#
|
31
|
+
# This expressions lets one register participants directly from a process
|
32
|
+
# definition.
|
33
|
+
#
|
34
|
+
# pdef = Ruote.define do
|
35
|
+
#
|
36
|
+
# registerp 'alpha', :class => 'MyParticipant', :target => 'mail'
|
37
|
+
# # register participant named 'alpha' with the given class
|
38
|
+
# # and some attributes
|
39
|
+
#
|
40
|
+
# registerp /^user_.+/, :class => 'MyParticipant'
|
41
|
+
# registerp :regex => '^user_.+', :class => 'MyParticipant'
|
42
|
+
# # register participant with a given regular expression
|
43
|
+
#
|
44
|
+
# registerp 'admin', :class => 'MyParticipant', :position => -2
|
45
|
+
# # register participant 'admin' as second to last in participant list
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# Participant info can be given as attributes to the expression (see code
|
49
|
+
# above) or via the workitem.
|
50
|
+
#
|
51
|
+
# pdef = Ruote.define do
|
52
|
+
#
|
53
|
+
# registerp :participant => 'participant'
|
54
|
+
# # participant info is found in the field 'participant'
|
55
|
+
#
|
56
|
+
# registerp :participants => 'participants'
|
57
|
+
# # an array of participant info is found in the field 'participants'
|
58
|
+
# end
|
59
|
+
#
|
60
|
+
# The expression 'unregisterp' can be used to remove participants from the
|
61
|
+
# participant list.
|
62
|
+
#
|
63
|
+
class RegisterpExpression < FlowExpression
|
64
|
+
|
65
|
+
names :registerp
|
66
|
+
|
67
|
+
def apply
|
68
|
+
|
69
|
+
registerp_allowed?
|
70
|
+
|
71
|
+
if pa = attribute('participant')
|
72
|
+
|
73
|
+
register_participant(h.applied_workitem['fields'][pa])
|
74
|
+
|
75
|
+
elsif pas = attribute('participants')
|
76
|
+
|
77
|
+
h.applied_workitem['fields'][pas].each do |part|
|
78
|
+
register_participant(part)
|
79
|
+
end
|
80
|
+
|
81
|
+
else
|
82
|
+
|
83
|
+
register_participant(attributes)
|
84
|
+
end
|
85
|
+
|
86
|
+
reply_to_parent(h.applied_workitem)
|
87
|
+
end
|
88
|
+
|
89
|
+
def reply(workitem)
|
90
|
+
|
91
|
+
# never called
|
92
|
+
end
|
93
|
+
|
94
|
+
protected
|
95
|
+
|
96
|
+
def registerp_allowed?
|
97
|
+
|
98
|
+
raise ArgumentError.new(
|
99
|
+
"'registerp_allowed' is set to false, cannot [un]register " +
|
100
|
+
"participants from process definitions"
|
101
|
+
) if context['registerp_allowed'] != true
|
102
|
+
end
|
103
|
+
|
104
|
+
def register_participant(info)
|
105
|
+
|
106
|
+
name, (klass, opts) = Ruote::ParticipantEntry.read(info)
|
107
|
+
|
108
|
+
context.engine.register_participant(name, klass, opts)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|