flor 0.18.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +3 -0
  3. data/CREDITS.md +1 -0
  4. data/LICENSE.txt +1 -1
  5. data/Makefile +1 -1
  6. data/README.md +15 -1
  7. data/flor.gemspec +1 -2
  8. data/lib/flor.rb +2 -2
  9. data/lib/flor/colours.rb +5 -3
  10. data/lib/flor/conf.rb +1 -0
  11. data/lib/flor/core.rb +9 -8
  12. data/lib/flor/core/executor.rb +20 -16
  13. data/lib/flor/core/node.rb +1 -13
  14. data/lib/flor/core/procedure.rb +10 -1
  15. data/lib/flor/core/texecutor.rb +9 -2
  16. data/lib/flor/djan.rb +1 -0
  17. data/lib/flor/errors.rb +1 -0
  18. data/lib/flor/flor.rb +144 -15
  19. data/lib/flor/id.rb +1 -0
  20. data/lib/flor/log.rb +2 -1
  21. data/lib/flor/migrations/0001_tables.rb +1 -0
  22. data/lib/flor/migrations/0002_cunit_and_munit.rb +1 -0
  23. data/lib/flor/migrations/0003_timer_onid_bnid.rb +1 -0
  24. data/lib/flor/migrations/0004_trap_bnid.rb +1 -0
  25. data/lib/flor/migrations/0005_pointer_content.rb +1 -0
  26. data/lib/flor/parser.rb +19 -11
  27. data/lib/flor/pcore/_apply.rb +1 -0
  28. data/lib/flor/pcore/_arr.rb +1 -0
  29. data/lib/flor/pcore/_atom.rb +1 -0
  30. data/lib/flor/pcore/_att.rb +1 -0
  31. data/lib/flor/pcore/_coll.rb +1 -0
  32. data/lib/flor/pcore/_dmute.rb +1 -0
  33. data/lib/flor/pcore/_dol.rb +1 -0
  34. data/lib/flor/pcore/_dqs.rb +1 -0
  35. data/lib/flor/pcore/_dump.rb +1 -0
  36. data/lib/flor/pcore/_err.rb +1 -0
  37. data/lib/flor/pcore/_head.rb +1 -0
  38. data/lib/flor/pcore/_obj.rb +1 -0
  39. data/lib/flor/pcore/_pat_.rb +1 -0
  40. data/lib/flor/pcore/_pat_arr.rb +1 -0
  41. data/lib/flor/pcore/_pat_guard.rb +1 -0
  42. data/lib/flor/pcore/_pat_obj.rb +1 -0
  43. data/lib/flor/pcore/_pat_or.rb +1 -0
  44. data/lib/flor/pcore/_pat_regex.rb +1 -0
  45. data/lib/flor/pcore/_ref.rb +1 -0
  46. data/lib/flor/pcore/_rxs.rb +1 -0
  47. data/lib/flor/pcore/_skip.rb +1 -0
  48. data/lib/flor/pcore/_val.rb +1 -0
  49. data/lib/flor/pcore/all.rb +1 -0
  50. data/lib/flor/pcore/andor.rb +1 -0
  51. data/lib/flor/pcore/any.rb +1 -0
  52. data/lib/flor/pcore/apply.rb +1 -0
  53. data/lib/flor/pcore/arith.rb +1 -0
  54. data/lib/flor/pcore/array_qmark.rb +1 -0
  55. data/lib/flor/pcore/break.rb +1 -0
  56. data/lib/flor/pcore/case.rb +1 -0
  57. data/lib/flor/pcore/cmp.rb +1 -0
  58. data/lib/flor/pcore/collect.rb +2 -1
  59. data/lib/flor/pcore/cond.rb +1 -0
  60. data/lib/flor/pcore/cursor.rb +45 -3
  61. data/lib/flor/pcore/define.rb +1 -0
  62. data/lib/flor/pcore/detect.rb +1 -0
  63. data/lib/flor/pcore/do_return.rb +1 -0
  64. data/lib/flor/pcore/each.rb +1 -0
  65. data/lib/flor/pcore/echo.rb +1 -0
  66. data/lib/flor/pcore/empty.rb +1 -0
  67. data/lib/flor/pcore/fail.rb +1 -0
  68. data/lib/flor/pcore/filter.rb +1 -0
  69. data/lib/flor/pcore/find.rb +1 -0
  70. data/lib/flor/pcore/flatten.rb +1 -0
  71. data/lib/flor/pcore/for_each.rb +1 -0
  72. data/lib/flor/pcore/if.rb +1 -0
  73. data/lib/flor/pcore/includes.rb +1 -0
  74. data/lib/flor/pcore/inject.rb +1 -0
  75. data/lib/flor/pcore/iterator.rb +1 -0
  76. data/lib/flor/pcore/keys.rb +1 -0
  77. data/lib/flor/pcore/length.rb +1 -0
  78. data/lib/flor/pcore/loop.rb +1 -0
  79. data/lib/flor/pcore/map.rb +1 -0
  80. data/lib/flor/pcore/match.rb +1 -0
  81. data/lib/flor/pcore/matchr.rb +1 -0
  82. data/lib/flor/pcore/max.rb +1 -0
  83. data/lib/flor/pcore/merge.rb +1 -0
  84. data/lib/flor/pcore/move.rb +1 -0
  85. data/lib/flor/pcore/noeval.rb +1 -0
  86. data/lib/flor/pcore/noret.rb +1 -0
  87. data/lib/flor/pcore/not.rb +1 -0
  88. data/lib/flor/pcore/on.rb +4 -3
  89. data/lib/flor/pcore/on_cancel.rb +1 -0
  90. data/lib/flor/pcore/on_error.rb +1 -0
  91. data/lib/flor/pcore/push.rb +1 -0
  92. data/lib/flor/pcore/rand.rb +1 -0
  93. data/lib/flor/pcore/range.rb +1 -0
  94. data/lib/flor/pcore/reduce.rb +1 -0
  95. data/lib/flor/pcore/return.rb +1 -0
  96. data/lib/flor/pcore/reverse.rb +1 -0
  97. data/lib/flor/pcore/select.rb +1 -0
  98. data/lib/flor/pcore/sequence.rb +1 -0
  99. data/lib/flor/pcore/set.rb +1 -0
  100. data/lib/flor/pcore/shuffle.rb +1 -0
  101. data/lib/flor/pcore/slice.rb +1 -0
  102. data/lib/flor/pcore/sort.rb +1 -0
  103. data/lib/flor/pcore/sort_by.rb +1 -0
  104. data/lib/flor/pcore/split.rb +1 -0
  105. data/lib/flor/pcore/stall.rb +1 -0
  106. data/lib/flor/pcore/strings.rb +1 -0
  107. data/lib/flor/pcore/timestamp.rb +1 -0
  108. data/lib/flor/pcore/to_array.rb +1 -0
  109. data/lib/flor/pcore/twig.rb +1 -0
  110. data/lib/flor/pcore/type_of.rb +1 -0
  111. data/lib/flor/pcore/until.rb +1 -0
  112. data/lib/flor/punit/abort.rb +50 -0
  113. data/lib/flor/punit/c_collect.rb +1 -0
  114. data/lib/flor/punit/c_each.rb +19 -0
  115. data/lib/flor/punit/c_for_each.rb +2 -1
  116. data/lib/flor/punit/c_iterator.rb +1 -0
  117. data/lib/flor/punit/c_map.rb +1 -0
  118. data/lib/flor/punit/cancel.rb +1 -0
  119. data/lib/flor/punit/concurrence.rb +1 -0
  120. data/lib/flor/punit/cron.rb +1 -0
  121. data/lib/flor/punit/do_trap.rb +1 -0
  122. data/lib/flor/punit/every.rb +1 -0
  123. data/lib/flor/punit/graft.rb +1 -0
  124. data/lib/flor/punit/m_ram.rb +1 -0
  125. data/lib/flor/punit/on_timeout.rb +1 -0
  126. data/lib/flor/punit/part.rb +1 -0
  127. data/lib/flor/punit/schedule.rb +1 -0
  128. data/lib/flor/punit/signal.rb +1 -0
  129. data/lib/flor/punit/sleep.rb +1 -0
  130. data/lib/flor/punit/task.rb +1 -0
  131. data/lib/flor/punit/trace.rb +1 -0
  132. data/lib/flor/punit/trap.rb +10 -1
  133. data/lib/flor/to_string.rb +1 -0
  134. data/lib/flor/tools/env.rb +1 -0
  135. data/lib/flor/tools/shell.rb +1 -0
  136. data/lib/flor/tools/shell_out.rb +1 -0
  137. data/lib/flor/tt.rb +98 -0
  138. data/lib/flor/unit.rb +2 -0
  139. data/lib/flor/unit/caller.rb +152 -19
  140. data/lib/flor/unit/caller_jruby.rb +132 -0
  141. data/lib/flor/unit/dump.rb +36 -0
  142. data/lib/flor/unit/executor.rb +1 -0
  143. data/lib/flor/unit/ganger.rb +6 -12
  144. data/lib/flor/unit/hloader.rb +34 -7
  145. data/lib/flor/unit/hook.rb +3 -0
  146. data/lib/flor/unit/hooker.rb +32 -15
  147. data/lib/flor/unit/journal.rb +23 -0
  148. data/lib/flor/unit/loader.rb +102 -7
  149. data/lib/flor/unit/logger.rb +24 -5
  150. data/lib/flor/unit/models.rb +8 -1
  151. data/lib/flor/unit/models/execution.rb +51 -0
  152. data/lib/flor/unit/models/message.rb +1 -0
  153. data/lib/flor/unit/models/pointer.rb +1 -0
  154. data/lib/flor/unit/models/timer.rb +1 -0
  155. data/lib/flor/unit/models/trace.rb +1 -0
  156. data/lib/flor/unit/models/trap.rb +3 -2
  157. data/lib/flor/unit/scheduler.rb +35 -28
  158. data/lib/flor/unit/spooler.rb +1 -0
  159. data/lib/flor/unit/storage.rb +68 -44
  160. data/lib/flor/unit/taskers.rb +2 -1
  161. data/lib/flor/unit/waiter.rb +2 -1
  162. data/lib/flor/unit/wlist.rb +10 -8
  163. metadata +13 -10
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module Flor
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'zlib'
3
4
 
@@ -30,9 +31,11 @@ module Flor
30
31
  #p [ :disconnected, @db.object_id ]
31
32
  end
32
33
 
33
- def db_version
34
+ def db_version(opts={})
34
35
 
35
- (@db[:schema_info].first rescue {})[:version]
36
+ table, column = migration_table_and_column(opts)
37
+
38
+ (@db[table].first rescue {})[column]
36
39
  end
37
40
 
38
41
  def migration_version
@@ -79,34 +82,27 @@ module Flor
79
82
  opts[:target] ||= to if to.is_a?(Integer)
80
83
  opts[:current] ||= from if from.is_a?(Integer)
81
84
 
82
- opts[:table] = (
83
- @unit.conf['db_migration_table'] ||
84
- @unit.conf['sto_migration_table'] ||
85
- :schema_info).to_sym
86
- opts[:column] = (
87
- @unit.conf['db_migration_column'] ||
88
- @unit.conf['sto_migration_column'] ||
89
- :version).to_sym
90
- #
91
- # defaults for the migration version table:
92
- # { table: :schema_info,
93
- # column: :version }
85
+ opts[:table], opts[:column] = migration_table_and_column(opts)
86
+ #
87
+ # defaults for the migration version table:
88
+ # { table: :schema_info,
89
+ # column: :version }
94
90
 
95
91
  skip =
92
+ opts[:sparse_migrations] ||
96
93
  @unit.conf['db_sparse_migrations'] ||
97
- @unit.conf['sto_sparse_migrations'] ||
98
- opts[:sparse_migrations]
94
+ @unit.conf['sto_sparse_migrations']
99
95
  if skip && ! opts.has_key?(:allow_missing_migration_files)
100
96
  opts[:allow_missing_migration_files] = true
101
97
  end
102
98
 
103
99
  dir =
100
+ opts[:migrations] ||
101
+ opts[:migration_dir] ||
104
102
  @unit.conf['db_migrations'] ||
105
103
  @unit.conf['db_migration_dir'] ||
106
104
  @unit.conf['sto_migrations'] ||
107
105
  @unit.conf['sto_migration_dir'] ||
108
- opts[:migrations] ||
109
- opts[:migration_dir] ||
110
106
  Flor.migration_dir
111
107
 
112
108
  synchronize do
@@ -336,35 +332,40 @@ module Flor
336
332
  n = Flor.tstamp
337
333
  u = @unit.identifier
338
334
 
339
- synchronize(syn) do
335
+ id =
336
+ synchronize(syn) do
340
337
 
341
- stored, unstored = ms.partition { |m| m['mid'] }
338
+ stored, unstored = ms.partition { |m| m['mid'] }
342
339
 
343
- #
344
- # de-reserve any previously stored message, might happen
345
- # for "terminated" messages that got queued back to let
346
- # other messages get processed
340
+ #
341
+ # de-reserve any previously stored message, might happen
342
+ # for "terminated" messages that got queued back to let
343
+ # other messages get processed
347
344
 
348
- @db[:flor_messages]
349
- .where(id: stored.collect { |m| m['mid'] })
350
- .update(status: 'created', mtime: n, munit: u) \
351
- if stored.any?
345
+ @db[:flor_messages]
346
+ .where(id: stored.collect { |m| m['mid'] })
347
+ .update(status: 'created', mtime: n, munit: u) \
348
+ if stored.any?
352
349
 
353
- #
354
- # store new messages
350
+ #
351
+ # store new messages
355
352
 
356
- @db[:flor_messages]
357
- .import(
358
- [ :domain, :exid, :point, :content,
359
- :status, :ctime, :mtime, :cunit, :munit ],
360
- unstored.map { |m|
361
- [ Flor.domain(m['exid']), m['exid'], m['point'], to_blob(m),
362
- 'created', n, n, u, u ] }) \
363
- if unstored.any?
364
- end
353
+ @db[:flor_messages]
354
+ .import(
355
+ [ :domain, :exid, :point, :content,
356
+ :status, :ctime, :mtime, :cunit, :munit ],
357
+ unstored.map { |m|
358
+ [ Flor.domain(m['exid']), m['exid'], m['point'], to_blob(m),
359
+ 'created', n, n, u, u ] }) \
360
+ if unstored.any?
361
+
362
+ @db[:flor_messages].max(:id)
363
+ end
365
364
 
366
365
  @unit.wake_up
367
366
 
367
+ id
368
+
368
369
  rescue => err
369
370
 
370
371
  Thread.current[:sto_errored_items] = ms
@@ -557,6 +558,18 @@ module Flor
557
558
 
558
559
  protected
559
560
 
561
+ def migration_table_and_column(opts={})
562
+
563
+ [ (opts[:migration_table] ||
564
+ @unit.conf['db_migration_table'] ||
565
+ @unit.conf['sto_migration_table'] ||
566
+ :schema_info).to_sym,
567
+ (opts[:migration_column] ||
568
+ @unit.conf['db_migration_column'] ||
569
+ @unit.conf['sto_migration_column'] ||
570
+ :version).to_sym ]
571
+ end
572
+
560
573
  def _commaify(o)
561
574
 
562
575
  if Flor.is_regex_tree?(o)
@@ -798,15 +811,26 @@ module Flor
798
811
  def error(msg); @unit.logger.db_log(:error, msg); end
799
812
  end
800
813
 
801
- def connect
814
+ def derive_db
815
+
816
+ db = @unit.conf['sto_db']
817
+
818
+ return db if db
802
819
 
803
820
  uri = @unit.conf['sto_uri']
804
821
 
805
- #uri = DB.uri if uri == 'DB' && defined?(DB)
806
- uri = (Kernel.const_get(uri).uri rescue uri) if uri.match(/\A[A-Z]+\z/)
807
- # for cases where `sto_uri: "DB"`
822
+ fail ArgumentError.new("no 'sto_uri' conf, cannot connect to db") \
823
+ unless uri
824
+
825
+ #uri = uri.to_s
826
+ #return Kernel.const_get(uri) if uri.match(/\A[A-Z]+\z/)
827
+
828
+ Sequel.connect(uri)
829
+ end
830
+
831
+ def connect
808
832
 
809
- @db = Sequel.connect(uri)
833
+ @db = derive_db
810
834
 
811
835
  class << @db; attr_accessor :flor_unit; end
812
836
  @db.flor_unit = @unit
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module Flor
3
4
 
@@ -88,7 +89,7 @@ module Flor
88
89
  return m if Flor.is_exid?(exid) && Flor.is_nid?(nid) && pl.is_a?(Hash)
89
90
 
90
91
  m = Flor.to_string_keyed_hash(m)
91
- h = Flor.dup(@message)
92
+ h = Flor.dup_message(@message)
92
93
  ks = m.keys
93
94
 
94
95
  if ks == [ 'payload' ]
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module Flor
3
4
 
@@ -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? row_match_var?
213
+ alias row_match_variable? row_match_var?
213
214
 
214
215
  def row_match_tasker?(unit, rs, nid, (name, value))
215
216
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module Flor
3
4
 
@@ -42,18 +43,19 @@ module Flor
42
43
 
43
44
  def notify(executor, message)
44
45
 
45
- @mutex.synchronize do
46
+ return [] unless message['consumed']
47
+ return [] if @msg_waiters.empty?
46
48
 
47
- to_remove = []
49
+ @mutex.synchronize do
48
50
 
49
- @msg_waiters.each do |w|
50
- remove = w.notify(executor, message)
51
- to_remove << w if remove
52
- end
51
+ to_remove =
52
+ @msg_waiters.each_with_object([]) do |w, a|
53
+ remove = w.notify(executor, message)
54
+ a << w if remove
55
+ end
53
56
 
54
57
  @msg_waiters -= to_remove
55
-
56
- end if message['consumed']
58
+ end
57
59
 
58
60
  [] # no new messages
59
61
  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: 0.18.0
4
+ version: 1.0.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: 2019-05-05 00:00:00.000000000 Z
11
+ date: 2020-11-22 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
@@ -249,8 +250,11 @@ files:
249
250
  - lib/flor/tools/env.rb
250
251
  - lib/flor/tools/shell.rb
251
252
  - lib/flor/tools/shell_out.rb
253
+ - lib/flor/tt.rb
252
254
  - lib/flor/unit.rb
253
255
  - lib/flor/unit/caller.rb
256
+ - lib/flor/unit/caller_jruby.rb
257
+ - lib/flor/unit/dump.rb
254
258
  - lib/flor/unit/executor.rb
255
259
  - lib/flor/unit/ganger.rb
256
260
  - lib/flor/unit/hloader.rb
@@ -272,16 +276,16 @@ files:
272
276
  - lib/flor/unit/taskers.rb
273
277
  - lib/flor/unit/waiter.rb
274
278
  - lib/flor/unit/wlist.rb
275
- homepage: http://github.com/floraison
279
+ homepage: https://github.com/floraison
276
280
  licenses:
277
281
  - MIT
278
282
  metadata:
279
- changelog_uri: http://github.com/floraison/flor/blob/master/CHANGELOG.md
280
- documentation_uri: http://github.com/floraison/flor/tree/master/doc
281
- bug_tracker_uri: http://github.com/floraison/flor/issues
283
+ changelog_uri: https://github.com/floraison/flor/blob/master/CHANGELOG.md
284
+ documentation_uri: https://github.com/floraison/flor/tree/master/doc
285
+ bug_tracker_uri: https://github.com/floraison/flor/issues
282
286
  mailing_list_uri: https://groups.google.com/forum/#!forum/floraison
283
- homepage_uri: http://github.com/floraison/flor
284
- source_code_uri: http://github.com/floraison/flor
287
+ homepage_uri: https://github.com/floraison/flor
288
+ source_code_uri: https://github.com/floraison/flor
285
289
  post_install_message:
286
290
  rdoc_options: []
287
291
  require_paths:
@@ -297,8 +301,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
297
301
  - !ruby/object:Gem::Version
298
302
  version: '0'
299
303
  requirements: []
300
- rubyforge_project:
301
- rubygems_version: 2.6.14.1
304
+ rubygems_version: 3.0.3
302
305
  signing_key:
303
306
  specification_version: 4
304
307
  summary: A Ruby workflow engine