flor 1.2.2 → 1.3.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/flor.rb +1 -1
- data/lib/flor/core/procedure.rb +8 -4
- data/lib/flor/log.rb +1 -1
- data/lib/flor/unit/scheduler.rb +9 -7
- data/lib/flor/unit/storage.rb +39 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a4ce441bf91802bac4b0d8f4377c5750a18e75e57afef69a77d474ba3d4ede4
|
4
|
+
data.tar.gz: fd068ae5ffa7ca790f1697621c5c6e82a23825a877d97be0d97410f2e1198f03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26abe012bdc4c4d6589217bf7df651d8f5d77cc027abf66d11d048207f3cf0ac91040f2dde45fbed327e33461de0f2e9527c3f06093ecc2db1f2252579840411
|
7
|
+
data.tar.gz: 9e754e16edd94b1795cbe5439fd24c62b8033bc0a93703283465be591fa29b7441282eacb65b71a57057367ff3443abb1ad86c558262f61a2ff5560c0528f8c0
|
data/CHANGELOG.md
CHANGED
data/lib/flor.rb
CHANGED
data/lib/flor/core/procedure.rb
CHANGED
@@ -5,7 +5,7 @@ class Flor::Procedure < Flor::Node
|
|
5
5
|
# "Returning vars" variables to pass back to pass upon reply.
|
6
6
|
# In the 'receive' messages, it's a hash under the key 'rvars'.
|
7
7
|
#
|
8
|
-
RVARS = %w[ idx ]
|
8
|
+
RVARS = %w[ idx ].freeze
|
9
9
|
|
10
10
|
# Attributes that when given alone are turned to "true" attributes.
|
11
11
|
#
|
@@ -13,7 +13,7 @@ class Flor::Procedure < Flor::Node
|
|
13
13
|
#
|
14
14
|
# The transformation occurs in Flor::Pro::Att ("_att").
|
15
15
|
#
|
16
|
-
TRUE_ATTS = %w[ flank off disabled ]
|
16
|
+
TRUE_ATTS = %w[ flank off disabled ].freeze
|
17
17
|
|
18
18
|
class << self
|
19
19
|
|
@@ -550,6 +550,8 @@ class Flor::Procedure < Flor::Node
|
|
550
550
|
wrap_reply
|
551
551
|
end
|
552
552
|
|
553
|
+
IF_UNLESS = %w[ _if _unless ].freeze
|
554
|
+
|
553
555
|
# Grab on_error proc from incoming payload and stores it into parent node.
|
554
556
|
#
|
555
557
|
# Has no effect if there is no parent node.
|
@@ -562,7 +564,7 @@ class Flor::Procedure < Flor::Node
|
|
562
564
|
@node; loop do
|
563
565
|
pnode = parent_node(pnode)
|
564
566
|
return unless pnode
|
565
|
-
break unless
|
567
|
+
break unless IF_UNLESS.include?(pnode['heap'])
|
566
568
|
end
|
567
569
|
|
568
570
|
flavour = "on_#{key}"
|
@@ -598,6 +600,8 @@ class Flor::Procedure < Flor::Node
|
|
598
600
|
wrap('point' => 'entered', 'nid' => nid, 'tags' => ret)
|
599
601
|
end
|
600
602
|
|
603
|
+
WRAP_KEYS = %w[ error cancel timeout ].freeze
|
604
|
+
|
601
605
|
def wrap(h={})
|
602
606
|
|
603
607
|
m = {}
|
@@ -642,7 +646,7 @@ class Flor::Procedure < Flor::Node
|
|
642
646
|
# was considering passing the whole vars back (as 'varz'), but
|
643
647
|
# it got in the way... and it might be heavy
|
644
648
|
|
645
|
-
|
649
|
+
WRAP_KEYS
|
646
650
|
.each { |k|
|
647
651
|
co = @node["child_on_#{k}"]
|
648
652
|
next unless co
|
data/lib/flor/log.rb
CHANGED
@@ -343,7 +343,7 @@ module Flor
|
|
343
343
|
o.puts(tree_to_s(node.lookup_tree(nid), nid, out: o)) if node
|
344
344
|
|
345
345
|
o.puts "#{_c.dg}node:#{_c.yl}"
|
346
|
-
o.puts YAML.dump(n.merge('tree' => '(above)'))
|
346
|
+
o.puts n ? YAML.dump(n.merge('tree' => '(above)')) : 'nil'
|
347
347
|
|
348
348
|
o.puts "#{_c.dg}nodes:#{_c.yl}"
|
349
349
|
o.puts nods_to_s(executor, m, opts)
|
data/lib/flor/unit/scheduler.rb
CHANGED
@@ -242,18 +242,18 @@ module Flor
|
|
242
242
|
end
|
243
243
|
end
|
244
244
|
|
245
|
+
RETURN_KEYS = %w[ exid nid payload tasker cause ].freeze
|
246
|
+
|
245
247
|
def return(message)
|
246
248
|
|
247
|
-
|
249
|
+
queue(
|
248
250
|
if message['point'] == 'failed'
|
249
251
|
message
|
250
252
|
else
|
251
253
|
message
|
252
|
-
.select { |k, _|
|
254
|
+
.select { |k, _| RETURN_KEYS.include?(k) }
|
253
255
|
.merge!('point' => 'return')
|
254
|
-
end
|
255
|
-
|
256
|
-
queue(m)
|
256
|
+
end)
|
257
257
|
|
258
258
|
nil
|
259
259
|
end
|
@@ -432,7 +432,7 @@ module Flor
|
|
432
432
|
ex ? ex.execution : nil
|
433
433
|
end
|
434
434
|
|
435
|
-
DUMP_KEYS = %w[ timestamp executions timers traps pointers ]
|
435
|
+
DUMP_KEYS = %w[ timestamp executions timers traps pointers ].freeze
|
436
436
|
|
437
437
|
# Dumps all or some of the executions to a JSON string.
|
438
438
|
# See Scheduler#load for importing.
|
@@ -598,6 +598,8 @@ module Flor
|
|
598
598
|
puts(on_start_exc(ex))
|
599
599
|
end
|
600
600
|
|
601
|
+
PREP_KEYS = %w[ exid name nid payload on_receive_last ].freeze
|
602
|
+
|
601
603
|
def prepare_message(point, args)
|
602
604
|
|
603
605
|
h = args
|
@@ -612,7 +614,7 @@ module Flor
|
|
612
614
|
opts = {}
|
613
615
|
|
614
616
|
h.each do |k, v|
|
615
|
-
if
|
617
|
+
if PREP_KEYS.include?(k)
|
616
618
|
msg[k] = v
|
617
619
|
else
|
618
620
|
opts[k.to_sym] = v
|
data/lib/flor/unit/storage.rb
CHANGED
@@ -220,6 +220,9 @@ module Flor
|
|
220
220
|
raise err
|
221
221
|
end
|
222
222
|
|
223
|
+
CRECON_STATUSES = %w[ created consumed ].freeze
|
224
|
+
RESCON_STATUSES = %w[ reserved consumed ].freeze
|
225
|
+
|
223
226
|
def load_messages(exe_count)
|
224
227
|
|
225
228
|
exe_count += 2
|
@@ -230,12 +233,12 @@ module Flor
|
|
230
233
|
_exids_being_processed =
|
231
234
|
@db[:flor_messages]
|
232
235
|
.select(:exid)
|
233
|
-
.exclude(status:
|
236
|
+
.exclude(status: CRECON_STATUSES)
|
234
237
|
_exids =
|
235
238
|
@db[:flor_messages]
|
236
239
|
.select(:exid)
|
237
240
|
.exclude(exid: _exids_being_processed)
|
238
|
-
.exclude(status:
|
241
|
+
.exclude(status: RESCON_STATUSES)
|
239
242
|
.limit(exe_count)
|
240
243
|
@db[:flor_messages]
|
241
244
|
.where(exid: _exids, status: 'created')
|
@@ -318,7 +321,7 @@ module Flor
|
|
318
321
|
[]
|
319
322
|
end
|
320
323
|
|
321
|
-
POINTS_TO_ARCHIVE = %w[ terminated failed ceased ]
|
324
|
+
POINTS_TO_ARCHIVE = %w[ terminated failed ceased ].freeze
|
322
325
|
|
323
326
|
def consume(messages)
|
324
327
|
|
@@ -686,6 +689,8 @@ module Flor
|
|
686
689
|
# done in update_pointers
|
687
690
|
end
|
688
691
|
|
692
|
+
FP_TYPES = %[ var ].freeze
|
693
|
+
|
689
694
|
def update_pointers(exe, status, now)
|
690
695
|
|
691
696
|
# Q Should we archive old pointers?
|
@@ -701,7 +706,7 @@ module Flor
|
|
701
706
|
|
702
707
|
@db[:flor_pointers]
|
703
708
|
.where(exid: exid)
|
704
|
-
.where(Sequel.|({ type:
|
709
|
+
.where(Sequel.|({ type: FP_TYPES }, Sequel.~(nid: exe['nodes'].keys)))
|
705
710
|
.delete
|
706
711
|
#
|
707
712
|
# Delete all pointer to vars, their value might have changed,
|
@@ -714,10 +719,14 @@ module Flor
|
|
714
719
|
pointers = exe['nodes']
|
715
720
|
.inject([]) { |a, (nid, node)|
|
716
721
|
|
722
|
+
# add a pointer for each tag
|
723
|
+
|
717
724
|
ts = node['tags']
|
718
725
|
ts.each { |t|
|
719
726
|
a << [ dom, exid, nid, 'tag', t, nil, now, u, nil ] } if ts
|
720
727
|
|
728
|
+
# add a pointer for each var (if nid == '0')
|
729
|
+
|
721
730
|
vs = nid == '0' ? node['vars'] : nil
|
722
731
|
vs.each { |k, v|
|
723
732
|
case v; when Numeric, String, TrueClass, FalseClass, NilClass
|
@@ -729,6 +738,8 @@ module Flor
|
|
729
738
|
a << [ dom, exid, '0', 'var', k, nil, now, u, v ]
|
730
739
|
end } if vs
|
731
740
|
|
741
|
+
# add a pointer for the task if any
|
742
|
+
|
732
743
|
if ta = node['task']
|
733
744
|
tasker = ta['tasker']
|
734
745
|
n = ta['name']; name = n.is_a?(String) ? n : JSON.dump(n)
|
@@ -736,6 +747,29 @@ module Flor
|
|
736
747
|
a << [ dom, exid, nid, 'tasker', tasker, name, now, u, content ]
|
737
748
|
end
|
738
749
|
|
750
|
+
# add a pointer for the error if any
|
751
|
+
|
752
|
+
if fa = node['failure']
|
753
|
+
|
754
|
+
#puts "-" * 80; pp node; puts "-" * 80
|
755
|
+
a <<
|
756
|
+
if er = fa['error']
|
757
|
+
ni = fa['from'] || nid # not nid /!\
|
758
|
+
nam = "#{er['kla']} l#{er['lin']}"
|
759
|
+
val = er['msg']
|
760
|
+
con = { error: fa, nid: ni }
|
761
|
+
[ dom, exid, ni, 'failure', nam, val, now, u, con ]
|
762
|
+
else
|
763
|
+
nam = fa['tasker'] || 'failure'
|
764
|
+
val = [ fa['attl'] || [], fa['attd'] || {} ]
|
765
|
+
.collect(&:inspect).join(' ')
|
766
|
+
con = { error: fa, nid: nid }
|
767
|
+
[ dom, exid, nid, 'failure', nam, val, now, u, con ]
|
768
|
+
end
|
769
|
+
end
|
770
|
+
|
771
|
+
# done
|
772
|
+
|
739
773
|
a }
|
740
774
|
|
741
775
|
cps = @db[:flor_pointers] # current pointers
|
@@ -747,16 +781,8 @@ module Flor
|
|
747
781
|
#
|
748
782
|
# don't insert when already inserted
|
749
783
|
|
750
|
-
#if pointer_columns.include?(:content)
|
751
784
|
pointers.each { |ptr| c = ptr[8]; ptr[8] = to_blob(c) if c }
|
752
|
-
|
753
|
-
# pointers.each { |ptr| ptr.pop }
|
754
|
-
#end
|
755
|
-
|
756
|
-
#@db[:flor_pointers]
|
757
|
-
# .import(
|
758
|
-
# pointer_columns,
|
759
|
-
# pointers)
|
785
|
+
|
760
786
|
@db[:flor_pointers]
|
761
787
|
.import(
|
762
788
|
POINTER_COLUMNS,
|
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: 1.
|
4
|
+
version: 1.3.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: 2021-
|
11
|
+
date: 2021-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: munemo
|