flor 0.17.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +48 -0
- data/CREDITS.md +1 -0
- data/LICENSE.txt +1 -1
- data/Makefile +1 -1
- data/README.md +34 -2
- data/flor.gemspec +8 -9
- data/lib/flor.rb +3 -2
- data/lib/flor/colours.rb +5 -3
- data/lib/flor/conf.rb +1 -0
- data/lib/flor/core.rb +9 -8
- data/lib/flor/core/executor.rb +25 -22
- data/lib/flor/core/node.rb +1 -13
- data/lib/flor/core/procedure.rb +57 -12
- data/lib/flor/core/texecutor.rb +35 -3
- data/lib/flor/djan.rb +1 -0
- data/lib/flor/errors.rb +1 -0
- data/lib/flor/flor.rb +173 -29
- data/lib/flor/id.rb +5 -1
- data/lib/flor/log.rb +20 -8
- data/lib/flor/migrations/0001_tables.rb +1 -0
- data/lib/flor/migrations/0002_cunit_and_munit.rb +1 -0
- data/lib/flor/migrations/0003_timer_onid_bnid.rb +1 -0
- data/lib/flor/migrations/0004_trap_bnid.rb +1 -0
- data/lib/flor/migrations/0005_pointer_content.rb +1 -0
- data/lib/flor/parser.rb +19 -11
- data/lib/flor/pcore/_apply.rb +1 -0
- data/lib/flor/pcore/_arr.rb +1 -0
- data/lib/flor/pcore/_atom.rb +1 -0
- data/lib/flor/pcore/_att.rb +1 -0
- data/lib/flor/pcore/_coll.rb +1 -0
- data/lib/flor/pcore/_dmute.rb +5 -1
- data/lib/flor/pcore/_dol.rb +1 -0
- data/lib/flor/pcore/_dqs.rb +1 -0
- data/lib/flor/pcore/_dump.rb +1 -0
- data/lib/flor/pcore/_err.rb +1 -0
- data/lib/flor/pcore/_head.rb +1 -0
- data/lib/flor/pcore/_obj.rb +1 -0
- data/lib/flor/pcore/_pat_.rb +1 -0
- data/lib/flor/pcore/_pat_arr.rb +1 -0
- data/lib/flor/pcore/_pat_guard.rb +1 -0
- data/lib/flor/pcore/_pat_obj.rb +1 -0
- data/lib/flor/pcore/_pat_or.rb +1 -0
- data/lib/flor/pcore/_pat_regex.rb +1 -0
- data/lib/flor/pcore/_ref.rb +1 -0
- data/lib/flor/pcore/_rxs.rb +1 -0
- data/lib/flor/pcore/_skip.rb +1 -0
- data/lib/flor/pcore/_val.rb +1 -0
- data/lib/flor/pcore/all.rb +1 -0
- data/lib/flor/pcore/andor.rb +1 -0
- data/lib/flor/pcore/any.rb +1 -0
- data/lib/flor/pcore/apply.rb +1 -0
- data/lib/flor/pcore/arith.rb +1 -0
- data/lib/flor/pcore/array_qmark.rb +1 -0
- data/lib/flor/pcore/break.rb +13 -1
- data/lib/flor/pcore/case.rb +1 -0
- data/lib/flor/pcore/cmp.rb +1 -0
- data/lib/flor/pcore/collect.rb +2 -1
- data/lib/flor/pcore/cond.rb +1 -0
- data/lib/flor/pcore/cursor.rb +45 -3
- data/lib/flor/pcore/define.rb +1 -0
- data/lib/flor/pcore/detect.rb +1 -0
- data/lib/flor/pcore/do_return.rb +1 -0
- data/lib/flor/pcore/each.rb +1 -0
- data/lib/flor/pcore/echo.rb +1 -0
- data/lib/flor/pcore/empty.rb +1 -0
- data/lib/flor/pcore/fail.rb +1 -0
- data/lib/flor/pcore/filter.rb +1 -0
- data/lib/flor/pcore/find.rb +1 -0
- data/lib/flor/pcore/flatten.rb +1 -0
- data/lib/flor/pcore/for_each.rb +1 -0
- data/lib/flor/pcore/if.rb +1 -0
- data/lib/flor/pcore/includes.rb +1 -0
- data/lib/flor/pcore/inject.rb +1 -0
- data/lib/flor/pcore/iterator.rb +1 -0
- data/lib/flor/pcore/keys.rb +1 -0
- data/lib/flor/pcore/length.rb +1 -0
- data/lib/flor/pcore/loop.rb +1 -0
- data/lib/flor/pcore/map.rb +1 -0
- data/lib/flor/pcore/match.rb +1 -0
- data/lib/flor/pcore/matchr.rb +1 -0
- data/lib/flor/pcore/max.rb +1 -0
- data/lib/flor/pcore/merge.rb +1 -0
- data/lib/flor/pcore/move.rb +1 -0
- data/lib/flor/pcore/noeval.rb +1 -0
- data/lib/flor/pcore/noret.rb +1 -0
- data/lib/flor/pcore/not.rb +1 -0
- data/lib/flor/pcore/on.rb +34 -9
- data/lib/flor/pcore/on_cancel.rb +1 -0
- data/lib/flor/pcore/on_error.rb +1 -0
- data/lib/flor/pcore/push.rb +1 -0
- data/lib/flor/pcore/rand.rb +1 -0
- data/lib/flor/pcore/range.rb +1 -0
- data/lib/flor/pcore/reduce.rb +1 -0
- data/lib/flor/pcore/return.rb +1 -0
- data/lib/flor/pcore/reverse.rb +1 -0
- data/lib/flor/pcore/select.rb +1 -0
- data/lib/flor/pcore/sequence.rb +49 -0
- data/lib/flor/pcore/set.rb +1 -0
- data/lib/flor/pcore/shuffle.rb +1 -0
- data/lib/flor/pcore/slice.rb +1 -0
- data/lib/flor/pcore/sort.rb +1 -0
- data/lib/flor/pcore/sort_by.rb +1 -0
- data/lib/flor/pcore/split.rb +1 -0
- data/lib/flor/pcore/stall.rb +1 -0
- data/lib/flor/pcore/strings.rb +1 -0
- data/lib/flor/pcore/timestamp.rb +1 -0
- data/lib/flor/pcore/to_array.rb +1 -0
- data/lib/flor/pcore/twig.rb +1 -0
- data/lib/flor/pcore/type_of.rb +1 -0
- data/lib/flor/pcore/until.rb +1 -0
- data/lib/flor/punit/abort.rb +50 -0
- data/lib/flor/punit/c_collect.rb +1 -0
- data/lib/flor/punit/c_each.rb +19 -0
- data/lib/flor/punit/c_for_each.rb +2 -1
- data/lib/flor/punit/c_iterator.rb +2 -1
- data/lib/flor/punit/c_map.rb +1 -0
- data/lib/flor/punit/cancel.rb +10 -1
- data/lib/flor/punit/concurrence.rb +7 -5
- data/lib/flor/punit/cron.rb +1 -0
- data/lib/flor/punit/do_trap.rb +1 -0
- data/lib/flor/punit/every.rb +1 -0
- data/lib/flor/punit/graft.rb +1 -0
- data/lib/flor/punit/{m_ram.rb → m_receive_and_merge.rb} +5 -4
- data/lib/flor/punit/on_timeout.rb +1 -0
- data/lib/flor/punit/part.rb +1 -0
- data/lib/flor/punit/schedule.rb +1 -0
- data/lib/flor/punit/signal.rb +30 -5
- data/lib/flor/punit/sleep.rb +1 -0
- data/lib/flor/punit/task.rb +9 -2
- data/lib/flor/punit/trace.rb +1 -0
- data/lib/flor/punit/trap.rb +41 -1
- data/lib/flor/to_string.rb +1 -0
- data/lib/flor/tools/env.rb +1 -0
- data/lib/flor/tools/firb.rb +33 -0
- data/lib/flor/tools/shell.rb +13 -3
- data/lib/flor/tools/shell_out.rb +1 -0
- data/lib/flor/tt.rb +98 -0
- data/lib/flor/unit.rb +3 -0
- data/lib/flor/unit/caller.rb +158 -23
- data/lib/flor/unit/caller_jruby.rb +133 -0
- data/lib/flor/unit/dump.rb +36 -0
- data/lib/flor/unit/executor.rb +28 -18
- data/lib/flor/unit/ganger.rb +30 -18
- data/lib/flor/unit/gangers.rb +125 -0
- data/lib/flor/unit/hloader.rb +34 -7
- data/lib/flor/unit/hook.rb +3 -0
- data/lib/flor/unit/hooker.rb +32 -15
- data/lib/flor/unit/journal.rb +23 -0
- data/lib/flor/unit/loader.rb +142 -15
- data/lib/flor/unit/logger.rb +35 -7
- data/lib/flor/unit/models.rb +48 -10
- data/lib/flor/unit/models/execution.rb +51 -0
- data/lib/flor/unit/models/message.rb +6 -0
- data/lib/flor/unit/models/pointer.rb +1 -0
- data/lib/flor/unit/models/timer.rb +1 -0
- data/lib/flor/unit/models/trace.rb +1 -0
- data/lib/flor/unit/models/trap.rb +15 -6
- data/lib/flor/unit/scheduler.rb +211 -61
- data/lib/flor/unit/spooler.rb +1 -0
- data/lib/flor/unit/storage.rb +117 -73
- data/lib/flor/unit/taskers.rb +115 -1
- data/lib/flor/unit/waiter.rb +22 -17
- data/lib/flor/unit/wlist.rb +19 -8
- metadata +26 -45
data/lib/flor/pcore/define.rb
CHANGED
data/lib/flor/pcore/detect.rb
CHANGED
data/lib/flor/pcore/do_return.rb
CHANGED
data/lib/flor/pcore/each.rb
CHANGED
data/lib/flor/pcore/echo.rb
CHANGED
data/lib/flor/pcore/empty.rb
CHANGED
data/lib/flor/pcore/fail.rb
CHANGED
data/lib/flor/pcore/filter.rb
CHANGED
data/lib/flor/pcore/find.rb
CHANGED
data/lib/flor/pcore/flatten.rb
CHANGED
data/lib/flor/pcore/for_each.rb
CHANGED
data/lib/flor/pcore/if.rb
CHANGED
data/lib/flor/pcore/includes.rb
CHANGED
data/lib/flor/pcore/inject.rb
CHANGED
data/lib/flor/pcore/iterator.rb
CHANGED
data/lib/flor/pcore/keys.rb
CHANGED
data/lib/flor/pcore/length.rb
CHANGED
data/lib/flor/pcore/loop.rb
CHANGED
data/lib/flor/pcore/map.rb
CHANGED
data/lib/flor/pcore/match.rb
CHANGED
data/lib/flor/pcore/matchr.rb
CHANGED
data/lib/flor/pcore/max.rb
CHANGED
data/lib/flor/pcore/merge.rb
CHANGED
data/lib/flor/pcore/move.rb
CHANGED
data/lib/flor/pcore/noeval.rb
CHANGED
data/lib/flor/pcore/noret.rb
CHANGED
data/lib/flor/pcore/not.rb
CHANGED
data/lib/flor/pcore/on.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
class Flor::Pro::On < Flor::Macro
|
3
4
|
#
|
@@ -100,6 +101,20 @@ class Flor::Pro::On < Flor::Macro
|
|
100
101
|
# If it were, it would trap the signal named "timeout".
|
101
102
|
#
|
102
103
|
#
|
104
|
+
# ## blocking mode
|
105
|
+
#
|
106
|
+
# When "on" is given no code block, it will block.
|
107
|
+
# ```
|
108
|
+
# sequence
|
109
|
+
# # ...
|
110
|
+
# on 'green' # execution (branch) blocks here until signal 'green' comes
|
111
|
+
# # ...
|
112
|
+
# ```
|
113
|
+
#
|
114
|
+
# Behind the scenes, it simply rewrites the "on" to a "trap" without a
|
115
|
+
# function, a blocking trap.
|
116
|
+
#
|
117
|
+
#
|
103
118
|
# ## see also
|
104
119
|
#
|
105
120
|
# Trap and signal.
|
@@ -111,13 +126,13 @@ class Flor::Pro::On < Flor::Macro
|
|
111
126
|
if att = find_catch # 22
|
112
127
|
rewrite_as_catch_tree(att)
|
113
128
|
else
|
114
|
-
|
129
|
+
rewrite_as_signal_trap_tree
|
115
130
|
end
|
116
131
|
end
|
117
132
|
|
118
133
|
protected
|
119
134
|
|
120
|
-
CATCHES = %w[ error cancel timeout ]
|
135
|
+
CATCHES = %w[ error cancel timeout ].freeze
|
121
136
|
|
122
137
|
def find_catch
|
123
138
|
|
@@ -151,7 +166,7 @@ class Flor::Pro::On < Flor::Macro
|
|
151
166
|
th
|
152
167
|
end
|
153
168
|
|
154
|
-
def
|
169
|
+
def rewrite_as_signal_trap_tree
|
155
170
|
|
156
171
|
atts = att_children
|
157
172
|
signame_i = atts.index { |at| at[1].size == 1 }
|
@@ -166,16 +181,26 @@ class Flor::Pro::On < Flor::Macro
|
|
166
181
|
l = tree[2]
|
167
182
|
|
168
183
|
th = [ 'trap', [], l, *tree[3] ]
|
184
|
+
|
169
185
|
th[1] << [ '_att', [ [ 'point', [], l ], [ '_sqs', 'signal', l ] ], l ]
|
170
186
|
th[1] << [ '_att', [ [ 'name', [], l ], tname ], l ]
|
171
|
-
th[1] << [ '_att', [ [ 'payload', [], l ], [ '_sqs', 'event', l ] ], l ]
|
172
|
-
atts.each { |ac| th[1] << Flor.dup(ac) }
|
173
187
|
|
174
|
-
|
175
|
-
|
176
|
-
|
188
|
+
att_names = []
|
189
|
+
atts.each { |at|
|
190
|
+
att_names << at[1][0][0]
|
191
|
+
th[1] << Flor.dup(at) }
|
177
192
|
|
178
|
-
th[1] <<
|
193
|
+
th[1] << [ '_att', [ [ 'payload', [], l ], [ '_sqs', 'event', l ] ], l ] \
|
194
|
+
unless att_names.include?('payload')
|
195
|
+
|
196
|
+
if (nac = non_att_children).any?
|
197
|
+
|
198
|
+
td = [ 'def', [], l ]
|
199
|
+
td[1] << [ '_att', [ [ 'msg', [], l ] ], l ]
|
200
|
+
non_att_children.each { |nac| td[1] << Flor.dup(nac) }
|
201
|
+
|
202
|
+
th[1] << td
|
203
|
+
end
|
179
204
|
|
180
205
|
th
|
181
206
|
end
|
data/lib/flor/pcore/on_cancel.rb
CHANGED
data/lib/flor/pcore/on_error.rb
CHANGED
data/lib/flor/pcore/push.rb
CHANGED
data/lib/flor/pcore/rand.rb
CHANGED
data/lib/flor/pcore/range.rb
CHANGED
data/lib/flor/pcore/reduce.rb
CHANGED
data/lib/flor/pcore/return.rb
CHANGED
data/lib/flor/pcore/reverse.rb
CHANGED
data/lib/flor/pcore/select.rb
CHANGED
data/lib/flor/pcore/sequence.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
class Flor::Pro::Sequence < Flor::Procedure
|
3
4
|
#
|
@@ -9,14 +10,62 @@ class Flor::Pro::Sequence < Flor::Procedure
|
|
9
10
|
# task 'bravo' if f.amount > 2000
|
10
11
|
# task 'charly'
|
11
12
|
# ```
|
13
|
+
#
|
14
|
+
# Giving a string as attribute result to "sequence" lets it interpret
|
15
|
+
# that string as a tag name, as in:
|
16
|
+
# ```
|
17
|
+
# sequence 'phase one'
|
18
|
+
# alice 'gather customer requirements'
|
19
|
+
# bob 'establish offer'
|
20
|
+
# sequence 'phase two'
|
21
|
+
# alice 'present offer to customer'
|
22
|
+
# bob 'sign contract'
|
23
|
+
# ```
|
24
|
+
# It is equivalent to:
|
25
|
+
# ```
|
26
|
+
# sequence tag: 'phase one'
|
27
|
+
# alice 'gather customer requirements'
|
28
|
+
# bob 'establish offer'
|
29
|
+
# sequence tag: 'phase two'
|
30
|
+
# alice 'present offer to customer'
|
31
|
+
# bob 'sign contract'
|
32
|
+
# ```
|
33
|
+
# Learn more about [tags](../tags.md).
|
34
|
+
#
|
35
|
+
# Please note that it sets only 1 tag, and if there are already tags
|
36
|
+
# sets (`sequence tags: [ 'a' 'b' ] "this won't become a tag"`), it won't set
|
37
|
+
# further tags.
|
38
|
+
#
|
39
|
+
# ## see also
|
40
|
+
#
|
41
|
+
# Concurrence, loop
|
12
42
|
|
13
43
|
names %w[ sequence begin ]
|
14
44
|
|
45
|
+
def receive_att
|
46
|
+
|
47
|
+
ms = []
|
48
|
+
|
49
|
+
ms = enter_tag \
|
50
|
+
if @node['tags'].nil? && payload_ret.is_a?(String) && from_unkeyed_att?
|
51
|
+
|
52
|
+
ms + super
|
53
|
+
end
|
54
|
+
|
15
55
|
def cancel_when_closed
|
16
56
|
|
17
57
|
return cancel if node_status_flavour == 'on-error'
|
18
58
|
|
19
59
|
[]
|
20
60
|
end
|
61
|
+
|
62
|
+
protected
|
63
|
+
|
64
|
+
def enter_tag
|
65
|
+
|
66
|
+
@node['tags'] = tags = [ payload_ret ]
|
67
|
+
|
68
|
+
wrap('point' => 'entered', 'nid' => nid, 'tags' => tags)
|
69
|
+
end
|
21
70
|
end
|
22
71
|
|
data/lib/flor/pcore/set.rb
CHANGED
data/lib/flor/pcore/shuffle.rb
CHANGED
data/lib/flor/pcore/slice.rb
CHANGED
data/lib/flor/pcore/sort.rb
CHANGED
data/lib/flor/pcore/sort_by.rb
CHANGED
data/lib/flor/pcore/split.rb
CHANGED
data/lib/flor/pcore/stall.rb
CHANGED
data/lib/flor/pcore/strings.rb
CHANGED
data/lib/flor/pcore/timestamp.rb
CHANGED
data/lib/flor/pcore/to_array.rb
CHANGED
data/lib/flor/pcore/twig.rb
CHANGED