flor 1.0.0 → 1.2.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: 7a1f76874a9957b7c15c59baf997e0e60ff4872b9109a7cd741692735a94565c
4
- data.tar.gz: 7fd1552910609023dd8bce0de0d5b5fc1ebc5ae1674fc27f0d0cb932c4bab2a7
3
+ metadata.gz: e89a3c4accc6ee1eca033031352f4c6d20c9b42ffbcb44aebe3cca04b59bc128
4
+ data.tar.gz: 30914f85dfb1f76de1877cdb60e977eff73cb1ee31d9dfa7b893160799b4c162
5
5
  SHA512:
6
- metadata.gz: cbca621e72efc0bdf1df26a4554590032f7a42d76ca19b361305f519071f1f026678c55c2980e74661ebcd5ac018d9e3e892376ee69a07c91ebb1d2d809cbb75
7
- data.tar.gz: b2c7cbe0a13c12f0e9b935c3d675f583d93a4f78f921982e75eb9050c84d97914c63cf9280667b5be977280cda9de27a57972f3f0d72b097710a6b3b1e45d67b
6
+ metadata.gz: 91cbcbbebccc7209554f49645a43876bf7f2743a77eac4a64ab3daf7f5fbfb8f2e7d566f6ffc03c932222aa2daf82e5674fd52a653bddd8b390b27cbb4714e1c
7
+ data.tar.gz: 174730b60ab5366c9cae335644ace73722ff52dc34477754020817c630dfabe1f6710846e437bbb936cb76fb4922f04d1dc2ffd2fde64f4c80924bd3dd7a629f
data/CHANGELOG.md CHANGED
@@ -2,7 +2,38 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
- ## flor 0.19.0 not yet released
5
+ ## flor 1.2.1 released 2021-03-22
6
+
7
+ * If conf sto_db_logger is false, do not attach a logger to the db connection
8
+
9
+
10
+ ## flor 1.2.0 released 2021-03-15
11
+
12
+ * Add #attd, #attl, #att_texts to Flor::Pointer
13
+
14
+
15
+ ## flor 1.1.1 released 2021-03-03
16
+
17
+ * Use YAML to have more compact msg_to_detail_s
18
+
19
+
20
+ ## flor 1.1.0 released 2021-01-06
21
+
22
+ * Introduce Tasker #set_payload and #set_vars
23
+ * Introduce the ModuleGanger
24
+ * Allow for domain/dot.json taskers
25
+ * Introduce Flor::StagedBasicTasker
26
+ * Fix service/executor issue in Caller
27
+
28
+
29
+ ## flor 1.0.1 released 2020-11-23
30
+
31
+ * Accept sto_uri strings pointing to constant like 'DB'
32
+
33
+
34
+ ## flor 1.0.0 released 2020-11-22
35
+
36
+ * Lots of incremental improvements
6
37
 
7
38
 
8
39
  ## flor 0.18.0 released 2019-05-05
data/LICENSE.txt CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- Copyright (c) 2015-2020, John Mettraux, jmettraux+flor@gmail.com
2
+ Copyright (c) 2015-2021, John Mettraux, jmettraux+flor@gmail.com
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  # flor
3
3
 
4
- [![Build Status](https://secure.travis-ci.org/floraison/flor.svg)](http://travis-ci.org/floraison/flor)
4
+ [![tests](https://github.com/floraison/flor/workflows/test/badge.svg)](https://github.com/floraison/flor/actions)
5
5
  [![Gem Version](https://badge.fury.io/rb/flor.svg)](http://badge.fury.io/rb/flor)
6
6
 
7
7
  Flor is a "Ruby workflow engine", if that makes any sense.
data/lib/flor.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'pp'
4
4
  require 'json'
5
+ require 'yaml'
5
6
  require 'logger'
6
7
  require 'thread'
7
8
  require 'digest'
@@ -15,7 +16,7 @@ require 'dense'
15
16
 
16
17
  module Flor
17
18
 
18
- VERSION = '1.0.0'
19
+ VERSION = '1.2.1'
19
20
  end
20
21
 
21
22
  require 'flor/colours'
@@ -254,7 +254,7 @@ module Flor
254
254
  o.each { |ee| ee['_path'] = path if ee.is_a?(Hash) }
255
255
  end
256
256
 
257
- o
257
+ rework_conf(o)
258
258
  end
259
259
 
260
260
  def interpret_path(path, context=nil)
@@ -299,6 +299,31 @@ module Flor
299
299
 
300
300
  ps.last == 'etc' ? File.absolute_path(File.join(dir, '..')) : dir
301
301
  end
302
+
303
+ protected
304
+
305
+ # For now, only the return procedure has to be marshalled back
306
+ # to the "return" string, gh-36
307
+ #
308
+ def rework_conf(o)
309
+
310
+ case o
311
+ when Array
312
+ o.collect { |e|
313
+ rework_conf(e) }
314
+ when Hash
315
+ o.inject({}) { |h, (k, v)|
316
+ h[k] =
317
+ if Flor.is_proc_tree?(v) && v[1]['proc'] == 'return'
318
+ 'return'
319
+ else
320
+ rework_conf(v)
321
+ end
322
+ h }
323
+ else
324
+ o
325
+ end
326
+ end
302
327
  end
303
328
  end
304
329
  end
data/lib/flor/flor.rb CHANGED
@@ -3,12 +3,11 @@
3
3
  module Flor
4
4
 
5
5
  NAME_REX = '[a-zA-Z0-9_]+'
6
- UNIT_NAME_REX = /\A#{NAME_REX}\z/
7
- DOMAIN_NAME_REX = /\A#{NAME_REX}(\.#{NAME_REX})*\z/
8
- FLOW_NAME_REX = /\A(#{NAME_REX}(?:\.#{NAME_REX})*)\.([a-zA-Z0-9_-]+)\z/
6
+ UNIT_NAME_REX = /\A#{NAME_REX}\z/.freeze
7
+ DOMAIN_NAME_REX = /\A#{NAME_REX}(\.#{NAME_REX})*\z/.freeze
8
+ FLOW_NAME_REX = /\A(#{NAME_REX}(?:\.#{NAME_REX})*)\.([a-zA-Z0-9_-]+)\z/.freeze
9
9
 
10
- #DOMAIN_UNIT_REX = /\A(#{NAME_REX}(?:\.#{NAME_REX})*)-(#{NAME_REX})[-\z]/
11
- DOMAIN_UNIT_REX = /\A(#{NAME_REX}(?:\.#{NAME_REX})*)-(#{NAME_REX})[-$]/
10
+ DOMAIN_UNIT_REX = /\A(#{NAME_REX}(?:\.#{NAME_REX})*)-(#{NAME_REX})[-$]/.freeze
12
11
 
13
12
  SPLAT_REGEX = /\A(.*)__(_|\d+)\z/.freeze
14
13
 
@@ -21,7 +20,7 @@ module Flor
21
20
  signal cancel
22
21
  terminated failed ceased
23
22
  idle
24
- ]
23
+ ].freeze
25
24
 
26
25
  class << self
27
26
 
@@ -280,13 +279,19 @@ module Flor
280
279
  #
281
280
  # functions about time
282
281
 
282
+ # Used by the storage in its next_time endeavours
283
+ #
284
+ def tstam
285
+ Time.now.utc.strftime('%FT%T')
286
+ end
287
+
283
288
  def isostamp(show_date, show_time, show_usec, time)
284
289
 
285
290
  t = (time || Time.now).utc
286
291
  s = StringIO.new
287
292
 
288
- s << t.strftime('%Y-%m-%d') if show_date
289
- s << t.strftime('T%H:%M:%S') if show_time
293
+ s << t.strftime('%F') if show_date # YYYY-mm-dd
294
+ s << t.strftime('T%T') if show_time # THH:MM:SS
290
295
  s << sprintf('.%06d', t.usec) if show_time && show_usec
291
296
  s << 'Z' if show_time
292
297
 
@@ -324,6 +329,11 @@ module Flor
324
329
  isostamp(false, true, true, t)
325
330
  end
326
331
 
332
+ def monow
333
+
334
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
335
+ end
336
+
327
337
  # def to_time(ts)
328
338
  #
329
339
  # m = ts.match(/\A(\d{4})(\d{2})(\d{2})\.(\d{2})(\d{2})(\d{2})(\d+)([uU]?)\z/)
@@ -368,11 +378,18 @@ module Flor
368
378
  sub_domain?(dom, sub)
369
379
  end
370
380
 
381
+ def dot_join(*elts)
382
+
383
+ elts.collect(&:to_s).select { |e| e.length > 0 }.join('.')
384
+ end
385
+
371
386
  def sub_domain?(dom, sub)
372
387
 
373
- dom == '' ||
374
- sub == dom ||
375
- sub[0, dom.length + 1] == dom + '.'
388
+ d = dom.is_a?(Array) ? dot_join(*dom) : dom.to_s
389
+
390
+ d == '' ||
391
+ sub == d ||
392
+ sub[0, d.length + 1] == d + '.'
376
393
  end
377
394
  alias subdomain? sub_domain?
378
395
 
data/lib/flor/id.rb CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  module Flor
4
4
 
5
+ NID_REX = /\A[0-9]+(?:_[0-9]+)*(?:-[0-9]+)?\z/.freeze
6
+ START_NID_REX = /\A[0-9]+(?:_[0-9]+)*(?:-[0-9]+)?/.freeze
7
+
5
8
  class << self
6
9
 
7
10
  #
@@ -99,7 +102,7 @@ module Flor
99
102
 
100
103
  def is_nid?(s)
101
104
 
102
- !! (s.is_a?(String) && s.match(/\A[0-9]+(?:_[0-9]+)*(?:-[0-9]+)?\z/))
105
+ !! (s.is_a?(String) && s.match(NID_REX))
103
106
  end
104
107
 
105
108
  def split_exid(s)
data/lib/flor/log.rb CHANGED
@@ -324,6 +324,7 @@ module Flor
324
324
  def msg_to_detail_s(executor, m, opts={})
325
325
 
326
326
  return if m['_detail_msg_flag']
327
+ #
327
328
  m['_detail_msg_flag'] = true if opts[:flag]
328
329
 
329
330
  o = StringIO.new
@@ -333,18 +334,22 @@ module Flor
333
334
  n = executor.execution['nodes'][nid]
334
335
  node = n ? Flor::Node.new(executor, n, m) : nil
335
336
 
336
- o.puts "#{_c.dg}<Flor.msg_to_detail_s>#{_c.rs}#{_c.yl}"
337
- o.puts Flor.to_pretty_s(m)
338
- o.puts "#{_c.dg}payload:#{_c.yl}"
339
- o.puts Flor.to_pretty_s(m['payload'], 0)
340
- o.puts "#{_c.dg}tree:"
337
+ o.puts "#{_c.rs}#{_c.dg}<Flor.msg_to_detail_s>"
338
+
339
+ o.puts "#{_c.dg}message:#{_c.yl}"
340
+ o.puts YAML.dump(m)
341
+
342
+ o.puts "#{_c.dg}tree:#{_c.yl}"
341
343
  o.puts(tree_to_s(node.lookup_tree(nid), nid, out: o)) if node
344
+
342
345
  o.puts "#{_c.dg}node:#{_c.yl}"
343
- o.puts(Flor.to_pretty_s(n)) if n
344
- o.puts "#{_c.dg}nodes:"
346
+ o.puts YAML.dump(n.merge('tree' => '(above)'))
347
+
348
+ o.puts "#{_c.dg}nodes:#{_c.yl}"
345
349
  o.puts nods_to_s(executor, m, opts)
346
350
  z = executor.execution['nodes'].size
347
351
  o.puts "#{_c.yl}#{z} node#{z == 1 ? '' : 's'}."
352
+
348
353
  o.puts "#{_c.dg}</Flor.msg_to_detail_s>#{_c.rs}"
349
354
 
350
355
  o.string
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'flor/punit/m_ram'
3
+ require 'flor/punit/m_receive_and_merge'
4
4
 
5
5
 
6
6
  # Parent class for "c-for-each" and "c-map"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'flor/punit/m_ram'
3
+ require 'flor/punit/m_receive_and_merge'
4
4
 
5
5
 
6
6
  class Flor::Pro::Concurrence < Flor::Procedure
@@ -387,10 +387,11 @@ class Flor::Pro::Concurrence < Flor::Procedure
387
387
 
388
388
  REWRITE_AS_ATTS = %w[
389
389
  on_receive on_merge
390
- child_on_error children_on_error ]
391
- #
392
- # heads of the child nodes that should get rewritten as attributes
393
- # of the concurrence ...
390
+ child_on_error children_on_error
391
+ ].freeze
392
+ #
393
+ # heads of the child nodes that should get rewritten as attributes
394
+ # of the concurrence ...
394
395
 
395
396
  def pre_execute_rewrite
396
397
 
@@ -179,15 +179,15 @@ module Flor::Pro::ReceiveAndMerge
179
179
  # * ignore
180
180
  # * stack
181
181
 
182
- STACK_REX = /\Astack(?::([-_a-zA-Z0-9]+))?\z/
182
+ STACK_REX = /\Astack(?::([-_a-zA-Z0-9]+))?\z/.freeze
183
183
 
184
- TRANSLATORS = { STACK_REX => 'k', /\Atail\z/ => 'a' }
184
+ TRANSLATORS = { STACK_REX => 'k', /\Atail\z/ => 'a' }.freeze
185
185
 
186
186
  MORDERS = {
187
- 'f' => :first, 'l' => :last, /[tnh]/ => :north, /[bsa]/ => :south }
187
+ 'f' => :first, 'l' => :last, /[tnh]/ => :north, /[bsa]/ => :south }.freeze
188
188
  MMERGERS = {
189
189
  'd' => :deep, /[mp]/ => :mix, 'o' => :override, 'i' => :ignore,
190
- 'k' => :stack }
190
+ 'k' => :stack }.freeze
191
191
 
192
192
  def default_merger
193
193
 
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'irb'
4
+
5
+ #require 'sequel'
6
+ require 'flor'
7
+ require 'flor/unit'
8
+
9
+
10
+ p [ RUBY_VERSION, RUBY_PLATFORM ]
11
+
12
+ puts
13
+
14
+ ENV.each do |k, v|
15
+ next unless k.match?(/RUBY|GEM/)
16
+ puts "* #{k}: #{v}"
17
+ end
18
+
19
+ ARGV.each do |arg|
20
+ if arg.match(/:/)
21
+ DB = Sequel.connect(arg)
22
+ p DB
23
+ end
24
+ end
25
+
26
+ #MODELS = [ :executions, :timers, :traces, :traps, :pointers, :messages ]
27
+ if defined?(DB)
28
+ Flor::Message.dataset = DB[:flor_messages]
29
+ end
30
+
31
+ ARGV.clear
32
+ IRB.start
33
+
@@ -15,11 +15,16 @@ module Flor::Tools
15
15
  def initialize(argv=nil)
16
16
 
17
17
  env = ENV['FLOR_ENV'] || 'shell'
18
- @root = "envs/#{env}"
18
+
19
+ @root = File.directory?(env) ? env : "envs/#{env}"
19
20
 
20
21
  prepare_home
21
22
 
22
- @unit = Flor::Unit.new("#{@root}/etc/conf.json")
23
+ over_conf = {}
24
+ #
25
+ c = ENV['FLOR_STO_URI']; over_conf['sto_uri'] = c if c
26
+
27
+ @unit = Flor::Unit.new("#{@root}/etc/conf.json", over_conf)
23
28
 
24
29
  @unit.conf['unit'] = 'cli'
25
30
  #unit.hooker.add('journal', Flor::Journal)
@@ -31,7 +36,11 @@ module Flor::Tools
31
36
  @mute = false
32
37
  @paging = true
33
38
 
34
- @unit.start
39
+ if ENV['FLOR_NO_START']
40
+ @unit.check_migration_version
41
+ else
42
+ @unit.start
43
+ end
35
44
 
36
45
  @flow_path = File.join(@root, 'home/scratch.flo')
37
46
  @ra_flow_path = File.join(@root, 'home/ra_scratch.flo')
data/lib/flor/unit.rb CHANGED
@@ -22,6 +22,7 @@ require 'flor/unit/loader'
22
22
  require 'flor/unit/hloader'
23
23
  require 'flor/unit/ganger'
24
24
  require 'flor/unit/spooler'
25
+ require 'flor/unit/gangers'
25
26
  require 'flor/unit/taskers'
26
27
 
27
28
  Flor.load_procedures('punit')
@@ -107,9 +107,11 @@ module Flor
107
107
  #
108
108
  # call
109
109
 
110
- p = message['point']
111
- ms = [ "on_#{p}", :on_message, :on, p ]
112
- ms = ms + [ :on_cancel, :cancel ] if p == 'detask'
110
+ pt = message['point']
111
+
112
+ ms = [ "call_#{pt}", "on_#{pt}", :on_message, :on, pt ]
113
+ ms = ms + [ :on_cancel, :cancel ] if pt == 'detask'
114
+
113
115
  m = ms.find { |mm| o.respond_to?(mm) }
114
116
 
115
117
  fail(
@@ -121,7 +123,7 @@ module Flor
121
123
  case o.method(m).arity
122
124
  when 1 then o.send(m, message)
123
125
  when 2 then o.send(m, conf, message)
124
- when 3 then o.send(m, executor, conf, message)
126
+ when 3 then o.send(m, service, conf, message)
125
127
  when -1 then o.send(m, {
126
128
  service: service, configuration: conf, message: message })
127
129
  else o.send(m)
@@ -23,7 +23,7 @@ module Flor
23
23
  @exitstatus = exitstatus
24
24
  end
25
25
 
26
- def pid; @process.pid; end
26
+ def pid; @process.pid; rescue; nil; end
27
27
  end
28
28
 
29
29
  def spawn(conf, data)
@@ -41,7 +41,7 @@ module Flor
41
41
  henv.each { |k, v| builder.environment.put(k, v) }
42
42
 
43
43
  process = builder.start
44
- pid = process.pid
44
+ pid = process.respond_to?(:pid) ? process.pid : nil
45
45
 
46
46
  o = process.outputStream.to_io
47
47
  i = process.inputStream.to_io
@@ -61,10 +61,12 @@ module Flor
61
61
 
62
62
  rescue => err
63
63
 
64
- Process.detach(pid) \
65
- if pid
66
- (Process.kill(9, pid) rescue nil) \
67
- unless Flor.no?(conf['on_error_kill'])
64
+ if pid
65
+ Process.detach(pid)
66
+ (Process.kill(9, pid) rescue nil) unless Flor.no?(conf['on_error_kill'])
67
+ else
68
+ process.destroy rescue nil
69
+ end
68
70
 
69
71
  raise err if err.is_a?(SpawnError)
70
72
  raise WrappedSpawnError.new(conf, { to: to, t0: t0, pid: pid }, err)
@@ -72,7 +74,6 @@ module Flor
72
74
  ensure
73
75
 
74
76
  [ i, o, f ].each { |x| x.close rescue nil }
75
-
76
77
  end
77
78
 
78
79
  module CmdParser include Raabro