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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1dae0857de545986e18ad31a41f37a6ead6687b34d3c06de22aafa606369283
4
- data.tar.gz: 9843d0124a2c3948ffc6846e7854854f5eda37d95bd02bfc02cecfefab0e5ea1
3
+ metadata.gz: 8a4ce441bf91802bac4b0d8f4377c5750a18e75e57afef69a77d474ba3d4ede4
4
+ data.tar.gz: fd068ae5ffa7ca790f1697621c5c6e82a23825a877d97be0d97410f2e1198f03
5
5
  SHA512:
6
- metadata.gz: 185490e0054ffdfe7c078b71955834679a398266e613be5d8bb6b63bc626bf4727bd4fd45249e7dea14cdd91a85c5ad92a1f6b3b120117c7c274b41d5478ba31
7
- data.tar.gz: e6dde7ae40f3ef6d2c7a620d6a07840c6591b745798962d039ac39fa426e4bcef51f3c67e97d9a367bb981918ec5fe98934393eec2cd7e87046b8d491b9a6511
6
+ metadata.gz: 26abe012bdc4c4d6589217bf7df651d8f5d77cc027abf66d11d048207f3cf0ac91040f2dde45fbed327e33461de0f2e9527c3f06093ecc2db1f2252579840411
7
+ data.tar.gz: 9e754e16edd94b1795cbe5439fd24c62b8033bc0a93703283465be591fa29b7441282eacb65b71a57057367ff3443abb1ad86c558262f61a2ff5560c0528f8c0
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## flor 1.3.0 released 2021-04-13
6
+
7
+ * Insert a row flor_pointers for 'failure'
8
+
9
+
5
10
  ## flor 1.2.2 released 2021-03-29
6
11
 
7
12
  * Include data in flor_pointers
data/lib/flor.rb CHANGED
@@ -16,7 +16,7 @@ require 'dense'
16
16
 
17
17
  module Flor
18
18
 
19
- VERSION = '1.2.2'
19
+ VERSION = '1.3.0'
20
20
  end
21
21
 
22
22
  require 'flor/colours'
@@ -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 %w[ _if _unless ].include?(pnode['heap'])
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
- %w[ error cancel timeout ]
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)
@@ -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
- m =
249
+ queue(
248
250
  if message['point'] == 'failed'
249
251
  message
250
252
  else
251
253
  message
252
- .select { |k, _| %w[ exid nid payload tasker cause ].include?(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 %w[ exid name nid payload on_receive_last ].include?(k)
617
+ if PREP_KEYS.include?(k)
616
618
  msg[k] = v
617
619
  else
618
620
  opts[k.to_sym] = v
@@ -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: %w[ created consumed ])
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: %w[ reserved consumed ])
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: %w[ var ] }, Sequel.~(nid: exe['nodes'].keys)))
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
- #else
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.2.2
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-03-29 00:00:00.000000000 Z
11
+ date: 2021-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: munemo