flor 1.1.1 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 553a980e772a1ce1d8990fc8d0744163b6615c5e9a4fe391d48ab73ac2219b2a
4
- data.tar.gz: 7b922c56e568ac51cbb9cc3dbcb02c930984f94785ddd3b8ea76804ccff848de
3
+ metadata.gz: 4d69af5b3896b5a00daa44d3fc0c60e08d9ee893916e5aeff81869cc35b2967e
4
+ data.tar.gz: 6a780ea13692c00c23826462de49ad87f32e036103200d530fd247b4208fb682
5
5
  SHA512:
6
- metadata.gz: fc920c9d3f305e3e31f174ebbb5d8e7f935742a9b5bcd5a75b80646d5803746315e91e4937156a01f3fcc512c477b8770e6a665a86bd61a81120f0e305027652
7
- data.tar.gz: 4dd48c11b6f59d2efc4aec15060d0c7db07541b1af4037dc8402b6ef701f43b88928aaaf3306e6ae0e1237a79f5fb360c992cf58648e26edb398f7adf843970e
6
+ metadata.gz: a39bbe96e2d6f5d48502c3c364b3fab6411098ab569aa3fec5ec8a3ae47e0c15bec321c312b6b70c9ef9f2cf49e5feced6e672fa3dbb0edd5f2772fea7007138
7
+ data.tar.gz: c46e23499dffdf92acd34ac2961b91d3cbeeafdd98b40e30fdb0de8110293eecc8fc0fa1e5e0cb842a769f4e9b85ecebb032b6686b2e547d716aeca2b6862d37
data/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## flor 1.3.1 released 2021-04-19
6
+
7
+ * Fix flor_pointers var deletion mechanism (type = ' var ')
8
+
9
+
10
+ ## flor 1.3.0 released 2021-04-13
11
+
12
+ * Insert a row flor_pointers for 'failure'
13
+
14
+
15
+ ## flor 1.2.2 released 2021-03-29
16
+
17
+ * Include data in flor_pointers
18
+ * Ensure flor_pointers name is a string
19
+
20
+
21
+ ## flor 1.2.1 released 2021-03-22
22
+
23
+ * If conf sto_db_logger is false, do not attach a logger to the db connection
24
+
25
+
26
+ ## flor 1.2.0 released 2021-03-15
27
+
28
+ * Add #attd, #attl, #att_texts to Flor::Pointer
29
+
30
+
5
31
  ## flor 1.1.1 released 2021-03-03
6
32
 
7
33
  * Use YAML to have more compact msg_to_detail_s
data/lib/flor.rb CHANGED
@@ -16,7 +16,7 @@ require 'dense'
16
16
 
17
17
  module Flor
18
18
 
19
- VERSION = '1.1.1'
19
+ VERSION = '1.3.1'
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)
@@ -30,7 +30,7 @@ module Flor
30
30
  #end
31
31
 
32
32
  # If the pointer is a "var" pointer, returns the full value
33
- # for the variable, as fund in the execution's node "0".
33
+ # for the variable, as found in the execution's node "0".
34
34
  #
35
35
  def full_value
36
36
 
@@ -38,6 +38,25 @@ module Flor
38
38
 
39
39
  node['vars'][name]
40
40
  end
41
+
42
+ def attd
43
+
44
+ data['atts'].inject({}) { |h, (k, v)| h[k] = v if k; h }
45
+
46
+ rescue; []
47
+ end
48
+
49
+ def attl
50
+
51
+ data['atts'].inject([]) { |a, (k, v)| a << v if k == nil; a }
52
+
53
+ rescue; []
54
+ end
55
+
56
+ def att_texts
57
+
58
+ attl.select { |e| e.is_a?(String) }
59
+ end
41
60
  end
42
61
  end
43
62
 
@@ -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
@@ -12,8 +12,9 @@ module Flor
12
12
  :status, :ctime, :mtime, :cunit, :munit
13
13
  ].freeze
14
14
  POINTER_COLUMNS = [
15
- :domain, :exid, :nid, :type, :name, :value, :ctime, :cunit
16
- ].freeze
15
+ :domain, :exid, :nid, :type, :name, :value, :ctime, :cunit,
16
+ :content
17
+ ].freeze
17
18
 
18
19
  attr_reader :unit, :db, :models
19
20
 
@@ -219,6 +220,9 @@ module Flor
219
220
  raise err
220
221
  end
221
222
 
223
+ CRECON_STATUSES = %w[ created consumed ].freeze
224
+ RESCON_STATUSES = %w[ reserved consumed ].freeze
225
+
222
226
  def load_messages(exe_count)
223
227
 
224
228
  exe_count += 2
@@ -229,12 +233,12 @@ module Flor
229
233
  _exids_being_processed =
230
234
  @db[:flor_messages]
231
235
  .select(:exid)
232
- .exclude(status: %w[ created consumed ])
236
+ .exclude(status: CRECON_STATUSES)
233
237
  _exids =
234
238
  @db[:flor_messages]
235
239
  .select(:exid)
236
240
  .exclude(exid: _exids_being_processed)
237
- .exclude(status: %w[ reserved consumed ])
241
+ .exclude(status: RESCON_STATUSES)
238
242
  .limit(exe_count)
239
243
  @db[:flor_messages]
240
244
  .where(exid: _exids, status: 'created')
@@ -317,7 +321,7 @@ module Flor
317
321
  []
318
322
  end
319
323
 
320
- POINTS_TO_ARCHIVE = %w[ terminated failed ceased ]
324
+ POINTS_TO_ARCHIVE = %w[ terminated failed ceased ].freeze
321
325
 
322
326
  def consume(messages)
323
327
 
@@ -685,6 +689,8 @@ module Flor
685
689
  # done in update_pointers
686
690
  end
687
691
 
692
+ FP_TYPES = %w[ var ].freeze
693
+
688
694
  def update_pointers(exe, status, now)
689
695
 
690
696
  # Q Should we archive old pointers?
@@ -700,7 +706,7 @@ module Flor
700
706
 
701
707
  @db[:flor_pointers]
702
708
  .where(exid: exid)
703
- .where(Sequel.|({ type: %w[ var ] }, Sequel.~(nid: exe['nodes'].keys)))
709
+ .where(Sequel.|({ type: FP_TYPES }, Sequel.~(nid: exe['nodes'].keys)))
704
710
  .delete
705
711
  #
706
712
  # Delete all pointer to vars, their value might have changed,
@@ -713,28 +719,57 @@ module Flor
713
719
  pointers = exe['nodes']
714
720
  .inject([]) { |a, (nid, node)|
715
721
 
722
+ # add a pointer for each tag
723
+
716
724
  ts = node['tags']
717
725
  ts.each { |t|
718
726
  a << [ dom, exid, nid, 'tag', t, nil, now, u, nil ] } if ts
719
727
 
728
+ # add a pointer for each var (if nid == '0')
729
+
720
730
  vs = nid == '0' ? node['vars'] : nil
721
731
  vs.each { |k, v|
722
732
  case v; when Numeric, String, TrueClass, FalseClass, NilClass
723
- a << [ dom, exid, '0', 'var', k, v.to_s, now, u, nil ]
733
+ a << [ dom, exid, '0', 'var', k, v.to_s, now, u, v ]
724
734
  when Array, Hash
725
735
  s = '(array)'; s = '(object)' if v.is_a?(Hash)
726
- a << [ dom, exid, '0', 'var', k, s, now, u, nil ]
736
+ a << [ dom, exid, '0', 'var', k, s, now, u, v ]
727
737
  else
728
- a << [ dom, exid, '0', 'var', k, nil, now, u, nil ]
738
+ a << [ dom, exid, '0', 'var', k, nil, now, u, v ]
729
739
  end } if vs
730
740
 
741
+ # add a pointer for the task if any
742
+
731
743
  if ta = node['task']
732
744
  tasker = ta['tasker']
733
- name = ta['name']
745
+ n = ta['name']; name = n.is_a?(String) ? n : JSON.dump(n)
734
746
  content = { message: node['message'], atts: node['atts'] }
735
747
  a << [ dom, exid, nid, 'tasker', tasker, name, now, u, content ]
736
748
  end
737
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
+
738
773
  a }
739
774
 
740
775
  cps = @db[:flor_pointers] # current pointers
@@ -746,29 +781,22 @@ module Flor
746
781
  #
747
782
  # don't insert when already inserted
748
783
 
749
- if pointer_columns.include?(:content)
750
- pointers.each { |ptr|
751
- c = ptr[8]; ptr[8] = to_blob(c) if c }
752
- else
753
- pointers.each { |ptr|
754
- ptr.pop }
755
- end
784
+ pointers.each { |ptr| c = ptr[8]; ptr[8] = to_blob(c) if c }
756
785
 
757
786
  @db[:flor_pointers]
758
787
  .import(
759
- pointer_columns,
788
+ POINTER_COLUMNS,
760
789
  pointers)
761
790
  end
762
791
 
763
- def pointer_columns
764
-
765
- @pointer_columns ||=
766
- if @db[:flor_pointers].columns.include?(:content)
767
- POINTER_COLUMNS + [ :content ]
768
- else
769
- POINTER_COLUMNS
770
- end
771
- end
792
+ #def pointer_columns
793
+ # @pointer_columns ||=
794
+ # if @db[:flor_pointers].columns.include?(:content)
795
+ # POINTER_COLUMNS + [ :content ]
796
+ # else
797
+ # POINTER_COLUMNS
798
+ # end
799
+ #end
772
800
 
773
801
  def determine_type_and_schedule(message)
774
802
 
@@ -849,8 +877,11 @@ module Flor
849
877
  # NB: -1 means "check at every use"
850
878
  end
851
879
 
852
- @db_logger = DbLogger.new(@unit)
853
- @db.loggers << @db_logger
880
+ if @unit.conf['sto_db_logger'] != false
881
+
882
+ @db_logger = DbLogger.new(@unit)
883
+ @db.loggers << @db_logger
884
+ end
854
885
  end
855
886
 
856
887
  class << self
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.1.1
4
+ version: 1.3.1
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-03 00:00:00.000000000 Z
11
+ date: 2021-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: munemo