flor 0.18.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +29 -0
- data/CREDITS.md +1 -0
- data/LICENSE.txt +1 -1
- data/Makefile +1 -1
- data/README.md +16 -2
- data/flor.gemspec +1 -2
- 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 +20 -16
- data/lib/flor/core/node.rb +1 -13
- data/lib/flor/core/procedure.rb +10 -1
- 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 +172 -26
- data/lib/flor/id.rb +5 -1
- data/lib/flor/log.rb +14 -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 +1 -0
- 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 +1 -0
- 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 +4 -3
- 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 +1 -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 +1 -0
- 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 +1 -0
- data/lib/flor/punit/sleep.rb +1 -0
- data/lib/flor/punit/task.rb +1 -0
- data/lib/flor/punit/trace.rb +1 -0
- data/lib/flor/punit/trap.rb +10 -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 +19 -13
- data/lib/flor/unit/ganger.rb +9 -12
- 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 +8 -1
- 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 +21 -1
- 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 +3 -2
- data/lib/flor/unit/scheduler.rb +51 -36
- data/lib/flor/unit/spooler.rb +1 -0
- data/lib/flor/unit/storage.rb +113 -84
- data/lib/flor/unit/taskers.rb +70 -1
- data/lib/flor/unit/waiter.rb +22 -17
- data/lib/flor/unit/wlist.rb +19 -8
- metadata +16 -11
data/lib/flor/unit/taskers.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
module Flor
|
3
4
|
|
@@ -28,6 +29,29 @@ module Flor
|
|
28
29
|
alias task_name taskname
|
29
30
|
|
30
31
|
def vars; @message['vars']; end
|
32
|
+
alias variables vars
|
33
|
+
|
34
|
+
def set_payload(h)
|
35
|
+
fail TypeError.new("not a hash but a #{fs.class}") unless h.is_a?(Hash)
|
36
|
+
@message['payload'] = h
|
37
|
+
end
|
38
|
+
alias set_fields set_payload
|
39
|
+
|
40
|
+
def set_vars(h)
|
41
|
+
fail TypeError.new("not a hash but a #{fs.class}") unless h.is_a?(Hash)
|
42
|
+
@message['vars'] = h
|
43
|
+
end
|
44
|
+
alias set_variables set_vars
|
45
|
+
|
46
|
+
#def merge_into_payload(h)
|
47
|
+
# @message['payload'].merge(h)
|
48
|
+
#end
|
49
|
+
#alias merge_into_fields merge_into_payload
|
50
|
+
#def merge_into_vars(h)
|
51
|
+
# @message['vars'].merge(h)
|
52
|
+
#end
|
53
|
+
#
|
54
|
+
# no for now, payload.merge(h) and vars.merge(h) do suffice
|
31
55
|
|
32
56
|
def execution
|
33
57
|
|
@@ -88,7 +112,7 @@ module Flor
|
|
88
112
|
return m if Flor.is_exid?(exid) && Flor.is_nid?(nid) && pl.is_a?(Hash)
|
89
113
|
|
90
114
|
m = Flor.to_string_keyed_hash(m)
|
91
|
-
h = Flor.
|
115
|
+
h = Flor.dup_message(@message)
|
92
116
|
ks = m.keys
|
93
117
|
|
94
118
|
if ks == [ 'payload' ]
|
@@ -111,5 +135,50 @@ module Flor
|
|
111
135
|
h
|
112
136
|
end
|
113
137
|
end
|
138
|
+
|
139
|
+
# A BasicTasker with stages (pre / on / post)
|
140
|
+
#
|
141
|
+
class StagedBasicTasker < BasicTasker
|
142
|
+
|
143
|
+
def call_task
|
144
|
+
|
145
|
+
call_one_of(:pre_task)
|
146
|
+
call_one_of(:on_task, :task)
|
147
|
+
end
|
148
|
+
|
149
|
+
def call_detask
|
150
|
+
|
151
|
+
call_one_of(:pre_detask, :pre_cancel)
|
152
|
+
call_one_of(:on_detask, :on_cancel, :detask, :cancel)
|
153
|
+
end
|
154
|
+
|
155
|
+
protected
|
156
|
+
|
157
|
+
def call_one_of(*ms)
|
158
|
+
|
159
|
+
m = ms.flatten.find { |mm| respond_to?(mm) }
|
160
|
+
|
161
|
+
send(m) if m
|
162
|
+
end
|
163
|
+
|
164
|
+
def reply(message=@message, force=false)
|
165
|
+
|
166
|
+
fail ArgumentError.new(
|
167
|
+
"argument to reply must be a Hash but is #{message.class}"
|
168
|
+
) unless message.is_a?(Hash)
|
169
|
+
|
170
|
+
pt = @message['point']
|
171
|
+
|
172
|
+
ms = [ "post_#{pt}" ]; ms << :post_cancel if pt == 'detask'
|
173
|
+
#
|
174
|
+
call_one_of(ms)
|
175
|
+
|
176
|
+
msg = derive_message(message)
|
177
|
+
|
178
|
+
@ganger.return(msg) if force || @ganger
|
179
|
+
|
180
|
+
[] # very important, return no further messages
|
181
|
+
end
|
182
|
+
end
|
114
183
|
end
|
115
184
|
|
data/lib/flor/unit/waiter.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
module Flor
|
3
4
|
|
@@ -22,7 +23,7 @@ module Flor
|
|
22
23
|
@executor = nil
|
23
24
|
end
|
24
25
|
|
25
|
-
ROW_PSEUDO_POINTS = %w[ status tag tasker var variable ]
|
26
|
+
ROW_PSEUDO_POINTS = %w[ status tag tasker var variable ].freeze
|
26
27
|
# "tasker", not "task", since "task" is already a message point
|
27
28
|
|
28
29
|
def row_waiter?
|
@@ -52,7 +53,7 @@ module Flor
|
|
52
53
|
|
53
54
|
@mutex.synchronize do
|
54
55
|
|
55
|
-
return false unless
|
56
|
+
return false unless msg_match?(message)
|
56
57
|
|
57
58
|
@serie.shift
|
58
59
|
return false if @serie.any?
|
@@ -150,7 +151,7 @@ module Flor
|
|
150
151
|
|
151
152
|
protected
|
152
153
|
|
153
|
-
def
|
154
|
+
def msg_match?(message)
|
154
155
|
|
155
156
|
mpoint = message['point']
|
156
157
|
|
@@ -209,7 +210,7 @@ module Flor
|
|
209
210
|
(name == nil || ptr.name == name) &&
|
210
211
|
(value == nil || ptr.value == value.to_s) }
|
211
212
|
end
|
212
|
-
alias row_match_variable?
|
213
|
+
alias row_match_variable? row_match_var?
|
213
214
|
|
214
215
|
def row_match_tasker?(unit, rs, nid, (name, value))
|
215
216
|
|
@@ -246,15 +247,7 @@ module Flor
|
|
246
247
|
end
|
247
248
|
end
|
248
249
|
|
249
|
-
|
250
|
-
%r{
|
251
|
-
\A
|
252
|
-
([0-9_\-]+)?[ ]*
|
253
|
-
(
|
254
|
-
[a-z]+(?::[^:|;,\s]+){0,2}
|
255
|
-
(?:[|, ][a-z]+(:[^:|;,\s]+){0,2})*
|
256
|
-
)\z
|
257
|
-
}x
|
250
|
+
PT_REX = /[a-z]+(?::[^:|,\s]+){0,2}/.freeze
|
258
251
|
|
259
252
|
def parse_serie(s)
|
260
253
|
|
@@ -262,11 +255,23 @@ module Flor
|
|
262
255
|
|
263
256
|
(s.is_a?(String) ? s.split(';') : s)
|
264
257
|
.collect { |ss|
|
265
|
-
|
258
|
+
|
259
|
+
k = StringScanner.new(ss.strip)
|
260
|
+
|
261
|
+
ni = k.scan(Flor::START_NID_REX)
|
262
|
+
|
263
|
+
k.scan(/\s*/)
|
264
|
+
|
265
|
+
pts = []; loop do
|
266
|
+
pt = k.scan(PT_REX); break unless pt
|
267
|
+
pts << pt
|
268
|
+
k.scan(/\s*[|,]\s*/)
|
269
|
+
end
|
270
|
+
|
266
271
|
fail ArgumentError.new(
|
267
|
-
"cannot parse #{ss.strip.inspect} wait directive") unless
|
268
|
-
|
269
|
-
[ ni,
|
272
|
+
"cannot parse #{ss.strip.inspect} wait directive") unless k.eos?
|
273
|
+
|
274
|
+
[ ni, pts ] }
|
270
275
|
end
|
271
276
|
end
|
272
277
|
end
|
data/lib/flor/unit/wlist.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
module Flor
|
3
4
|
|
@@ -11,6 +12,15 @@ module Flor
|
|
11
12
|
# `wtl_row_frequency`:
|
12
13
|
# sleep time between row waiter checks, defaults to 1
|
13
14
|
|
15
|
+
# Regular waiters are message waiters, they wait for a message
|
16
|
+
# that matches a pattern
|
17
|
+
#
|
18
|
+
# Row waiters are waiting for the pattern to realize in the database
|
19
|
+
# a better name would probably have been "query waiter".
|
20
|
+
# Row waiters need their own thread for checking at interval.
|
21
|
+
# Row waiters can live in a different Ruby process from the Ruby process
|
22
|
+
# performing the executions.
|
23
|
+
|
14
24
|
DEFAULT_TIMEOUT = Flor.env_i('FLOR_DEFAULT_TIMEOUT')
|
15
25
|
|
16
26
|
def initialize(unit)
|
@@ -42,18 +52,19 @@ module Flor
|
|
42
52
|
|
43
53
|
def notify(executor, message)
|
44
54
|
|
45
|
-
|
55
|
+
return [] unless message['consumed']
|
56
|
+
return [] if @msg_waiters.empty?
|
46
57
|
|
47
|
-
|
58
|
+
@mutex.synchronize do
|
48
59
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
60
|
+
to_remove =
|
61
|
+
@msg_waiters.each_with_object([]) do |w, a|
|
62
|
+
remove = w.notify(executor, message)
|
63
|
+
a << w if remove
|
64
|
+
end
|
53
65
|
|
54
66
|
@msg_waiters -= to_remove
|
55
|
-
|
56
|
-
end if message['consumed']
|
67
|
+
end
|
57
68
|
|
58
69
|
[] # no new messages
|
59
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mettraux
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: munemo
|
@@ -225,6 +225,7 @@ files:
|
|
225
225
|
- lib/flor/pcore/twig.rb
|
226
226
|
- lib/flor/pcore/type_of.rb
|
227
227
|
- lib/flor/pcore/until.rb
|
228
|
+
- lib/flor/punit/abort.rb
|
228
229
|
- lib/flor/punit/c_collect.rb
|
229
230
|
- lib/flor/punit/c_each.rb
|
230
231
|
- lib/flor/punit/c_for_each.rb
|
@@ -236,7 +237,7 @@ files:
|
|
236
237
|
- lib/flor/punit/do_trap.rb
|
237
238
|
- lib/flor/punit/every.rb
|
238
239
|
- lib/flor/punit/graft.rb
|
239
|
-
- lib/flor/punit/
|
240
|
+
- lib/flor/punit/m_receive_and_merge.rb
|
240
241
|
- lib/flor/punit/on_timeout.rb
|
241
242
|
- lib/flor/punit/part.rb
|
242
243
|
- lib/flor/punit/schedule.rb
|
@@ -247,12 +248,17 @@ files:
|
|
247
248
|
- lib/flor/punit/trap.rb
|
248
249
|
- lib/flor/to_string.rb
|
249
250
|
- lib/flor/tools/env.rb
|
251
|
+
- lib/flor/tools/firb.rb
|
250
252
|
- lib/flor/tools/shell.rb
|
251
253
|
- lib/flor/tools/shell_out.rb
|
254
|
+
- lib/flor/tt.rb
|
252
255
|
- lib/flor/unit.rb
|
253
256
|
- lib/flor/unit/caller.rb
|
257
|
+
- lib/flor/unit/caller_jruby.rb
|
258
|
+
- lib/flor/unit/dump.rb
|
254
259
|
- lib/flor/unit/executor.rb
|
255
260
|
- lib/flor/unit/ganger.rb
|
261
|
+
- lib/flor/unit/gangers.rb
|
256
262
|
- lib/flor/unit/hloader.rb
|
257
263
|
- lib/flor/unit/hook.rb
|
258
264
|
- lib/flor/unit/hooker.rb
|
@@ -272,16 +278,16 @@ files:
|
|
272
278
|
- lib/flor/unit/taskers.rb
|
273
279
|
- lib/flor/unit/waiter.rb
|
274
280
|
- lib/flor/unit/wlist.rb
|
275
|
-
homepage:
|
281
|
+
homepage: https://github.com/floraison
|
276
282
|
licenses:
|
277
283
|
- MIT
|
278
284
|
metadata:
|
279
|
-
changelog_uri:
|
280
|
-
documentation_uri:
|
281
|
-
bug_tracker_uri:
|
285
|
+
changelog_uri: https://github.com/floraison/flor/blob/master/CHANGELOG.md
|
286
|
+
documentation_uri: https://github.com/floraison/flor/tree/master/doc
|
287
|
+
bug_tracker_uri: https://github.com/floraison/flor/issues
|
282
288
|
mailing_list_uri: https://groups.google.com/forum/#!forum/floraison
|
283
|
-
homepage_uri:
|
284
|
-
source_code_uri:
|
289
|
+
homepage_uri: https://github.com/floraison/flor
|
290
|
+
source_code_uri: https://github.com/floraison/flor
|
285
291
|
post_install_message:
|
286
292
|
rdoc_options: []
|
287
293
|
require_paths:
|
@@ -297,8 +303,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
297
303
|
- !ruby/object:Gem::Version
|
298
304
|
version: '0'
|
299
305
|
requirements: []
|
300
|
-
|
301
|
-
rubygems_version: 2.6.14.1
|
306
|
+
rubygems_version: 3.0.3
|
302
307
|
signing_key:
|
303
308
|
specification_version: 4
|
304
309
|
summary: A Ruby workflow engine
|