flor 0.9.5 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +10 -0
- data/Makefile +13 -5
- data/README.md +0 -35
- data/flor.gemspec +1 -0
- data/lib/flor.rb +6 -24
- data/lib/flor/changes.rb +26 -0
- data/lib/flor/colours.rb +65 -31
- data/lib/flor/conf.rb +84 -54
- data/lib/flor/core.rb +0 -23
- data/lib/flor/core/executor.rb +12 -42
- data/lib/flor/core/node.rb +19 -24
- data/lib/flor/core/procedure.rb +13 -24
- data/lib/flor/core/texecutor.rb +10 -28
- data/lib/flor/deep.rb +152 -0
- data/lib/flor/djan.rb +200 -0
- data/lib/flor/dollar.rb +0 -24
- data/lib/flor/errors.rb +0 -24
- data/lib/flor/flor.rb +43 -296
- data/lib/flor/id.rb +90 -0
- data/lib/flor/log.rb +12 -35
- data/lib/flor/migrations/0002_cunit_and_munit.rb +86 -0
- data/lib/flor/parser.rb +40 -46
- data/lib/flor/pcore/_arr.rb +0 -24
- data/lib/flor/pcore/_atom.rb +0 -24
- data/lib/flor/pcore/_att.rb +3 -25
- data/lib/flor/pcore/_dump.rb +0 -24
- data/lib/flor/pcore/_err.rb +0 -24
- data/lib/flor/pcore/_happly.rb +0 -24
- data/lib/flor/pcore/_obj.rb +0 -24
- data/lib/flor/pcore/_skip.rb +0 -24
- data/lib/flor/pcore/arith.rb +0 -24
- data/lib/flor/pcore/break.rb +0 -24
- data/lib/flor/pcore/case.rb +127 -0
- data/lib/flor/pcore/cmp.rb +0 -24
- data/lib/flor/pcore/cond.rb +24 -24
- data/lib/flor/pcore/cursor.rb +0 -24
- data/lib/flor/pcore/define.rb +0 -24
- data/lib/flor/pcore/fail.rb +0 -24
- data/lib/flor/pcore/if.rb +39 -0
- data/lib/flor/pcore/loop.rb +0 -24
- data/lib/flor/pcore/map.rb +0 -24
- data/lib/flor/pcore/match.rb +0 -24
- data/lib/flor/pcore/move.rb +0 -24
- data/lib/flor/pcore/noeval.rb +0 -24
- data/lib/flor/pcore/noret.rb +0 -24
- data/lib/flor/pcore/push.rb +1 -25
- data/lib/flor/pcore/rand.rb +59 -0
- data/lib/flor/pcore/sequence.rb +0 -24
- data/lib/flor/pcore/set.rb +0 -24
- data/lib/flor/pcore/stall.rb +0 -24
- data/lib/flor/pcore/until.rb +0 -24
- data/lib/flor/pcore/val.rb +0 -24
- data/lib/flor/punit/cancel.rb +0 -24
- data/lib/flor/punit/cmap.rb +0 -24
- data/lib/flor/punit/concurrence.rb +54 -24
- data/lib/flor/punit/every.rb +0 -24
- data/lib/flor/punit/graft.rb +41 -0
- data/lib/flor/punit/on.rb +0 -24
- data/lib/flor/punit/schedule.rb +0 -24
- data/lib/flor/punit/signal.rb +0 -24
- data/lib/flor/punit/sleep.rb +0 -24
- data/lib/flor/punit/task.rb +0 -26
- data/lib/flor/punit/trace.rb +0 -24
- data/lib/flor/punit/trap.rb +0 -24
- data/lib/flor/to_string.rb +4 -25
- data/lib/flor/tools/env.rb +0 -23
- data/lib/flor/tools/shell.rb +810 -0
- data/lib/flor/unit.rb +0 -23
- data/lib/flor/unit/executor.rb +35 -31
- data/lib/flor/unit/ganger.rb +9 -34
- data/lib/flor/unit/hooker.rb +5 -25
- data/lib/flor/unit/journal.rb +0 -23
- data/lib/flor/unit/loader.rb +63 -94
- data/lib/flor/unit/logger.rb +8 -27
- data/lib/flor/unit/models.rb +0 -24
- data/lib/flor/unit/models/execution.rb +13 -24
- data/lib/flor/unit/models/pointer.rb +0 -24
- data/lib/flor/unit/models/timer.rb +0 -24
- data/lib/flor/unit/models/trace.rb +0 -24
- data/lib/flor/unit/models/trap.rb +0 -24
- data/lib/flor/unit/scheduler.rb +157 -128
- data/lib/flor/unit/storage.rb +224 -167
- data/lib/flor/unit/taskers.rb +38 -25
- data/lib/flor/unit/waiter.rb +7 -26
- data/lib/flor/unit/wlist.rb +8 -24
- metadata +28 -7
- data/fail.txt +0 -16
- data/intercepted.txt +0 -123
- data/lib/flor/pcore/ife.rb +0 -56
- data/lib/flor/tools/repl.rb +0 -231
- data/out.txt +0 -206
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
# flor CHANGELOG.md
|
3
3
|
|
4
4
|
|
5
|
+
## flor 0.10.0 released 2017-03-03
|
6
|
+
|
7
|
+
- Enhance shell, bring in bin/flosh (though not in gem)
|
8
|
+
- Rework "deep" tools (accept square bracket indexes)
|
9
|
+
- Implement vanilla "case"
|
10
|
+
- Implement "graft"
|
11
|
+
- Link unit name and unit identifier
|
12
|
+
- Scheduler rework, emphasis on optimistic locking for messages and timers
|
13
|
+
|
14
|
+
|
5
15
|
## flor 0.9.5 released 2017-02-10
|
6
16
|
|
7
17
|
- Don't load exids for which there are "loaded" messages
|
data/Makefile
CHANGED
@@ -34,16 +34,20 @@ push: build
|
|
34
34
|
## flor tasks ##
|
35
35
|
|
36
36
|
RUBY=bundle exec ruby
|
37
|
+
#RUBY=bundle exec ruby --disable-did_you_mean
|
38
|
+
# gem uninstall did_you_mean
|
39
|
+
|
37
40
|
FLOR_ENV?=dev
|
38
41
|
TO?=nil
|
39
42
|
FROM?=nil
|
40
43
|
|
44
|
+
|
41
45
|
migrate:
|
42
46
|
$(RUBY) -Ilib -e "require 'flor/unit'; Flor::Unit.new('envs/$(FLOR_ENV)/etc/conf.json').storage.migrate($(TO), $(FROM))"
|
43
47
|
|
44
48
|
start:
|
45
49
|
$(RUBY) -Ilib -e "require 'flor/unit'; Flor::Unit.new('envs/$(FLOR_ENV)/etc/conf.json').start.join"
|
46
|
-
s: start
|
50
|
+
#s: start
|
47
51
|
|
48
52
|
|
49
53
|
## misc tasks ##
|
@@ -62,9 +66,13 @@ mk:
|
|
62
66
|
doc:
|
63
67
|
$(RUBY) -Imak -r 'doc' -e "make_procedures_doc()"
|
64
68
|
|
65
|
-
|
66
|
-
$(RUBY) -Ilib -r 'flor/tools/
|
67
|
-
|
69
|
+
shell:
|
70
|
+
$(RUBY) -Ilib -r 'flor/tools/shell' -e 'Flor::Tools::Shell.new'
|
71
|
+
sh: shell
|
72
|
+
|
73
|
+
cleanshell:
|
74
|
+
rm -f envs/shell/var/flor.db
|
75
|
+
rm -fR envs/shell/var/tasks/*
|
68
76
|
|
69
|
-
.PHONY: doc
|
77
|
+
.PHONY: doc shell cleanshell
|
70
78
|
|
data/README.md
CHANGED
@@ -25,41 +25,6 @@ Flor is a "Ruby workflow engine", if that makes any sense.
|
|
25
25
|
|
26
26
|
see [doc/](doc/).
|
27
27
|
|
28
|
-
## Running the specs
|
29
|
-
|
30
|
-
(Most of the time, as developer of flor, I'm writing specs, running them with `FLOR_DEBUG=dbg` and hammering the code until the specs are green. The following lines are about setting `FLOR_DEBUG` for flor development).
|
31
|
-
|
32
|
-
##### setting FLOR_DEBUG
|
33
|
-
|
34
|
-
This is a targetted run of a spec file:
|
35
|
-
```
|
36
|
-
FLOR_DEBUG=msg,err bundle exec rspec spec/punit/cancel_spec.rb
|
37
|
-
```
|
38
|
-
|
39
|
-
* `msg` displays the flor messages in a summary, colored format
|
40
|
-
* `err` displays errors with details, when and if they happen
|
41
|
-
* `src` displays the source before it gets parsed and launched
|
42
|
-
* `tree` displays the syntax tree as parsed from the source, right before launch
|
43
|
-
* `run` shows info about each [run](doc/glossary.md#run) that just ended
|
44
|
-
* `sto` displays debug information about the [storage](doc/glossary.md#storage), it's mostly SQL statements
|
45
|
-
|
46
|
-
#### `FLOR_DEBUG=dbg` and `FLOR_DEBUG=all`
|
47
|
-
|
48
|
-
There are two shortcuts for the flags above:
|
49
|
-
```
|
50
|
-
FLOR_DEBUG=dbg bundle exec rspec spec/punit/cancel_spec.rb
|
51
|
-
# is equivalent to
|
52
|
-
FLOR_DEBUG=msg,err,src,tree,run bundle exec rspec spec/punit/cancel_spec.rb
|
53
|
-
```
|
54
|
-
and
|
55
|
-
```
|
56
|
-
FLOR_DEBUG=all bundle exec rspec spec/punit/cancel_spec.rb
|
57
|
-
# is equivalent to
|
58
|
-
FLOR_DEBUG=msg,err,src,tree,run,log,sto bundle exec rspec spec/punit/cancel_spec.rb
|
59
|
-
```
|
60
|
-
|
61
|
-
I tend to use `FLOR_DEBUG=dbg` when developping flor.
|
62
|
-
|
63
28
|
|
64
29
|
## LICENSE
|
65
30
|
|
data/flor.gemspec
CHANGED
data/lib/flor.rb
CHANGED
@@ -1,32 +1,10 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#
|
22
|
-
# Made in Japan.
|
23
|
-
#++
|
24
1
|
|
25
2
|
require 'pp'
|
26
3
|
require 'json'
|
27
4
|
require 'logger'
|
28
5
|
require 'thread'
|
29
6
|
require 'digest'
|
7
|
+
require 'socket'
|
30
8
|
|
31
9
|
require 'munemo'
|
32
10
|
require 'raabro'
|
@@ -34,17 +12,21 @@ require 'raabro'
|
|
34
12
|
|
35
13
|
module Flor
|
36
14
|
|
37
|
-
VERSION = '0.
|
15
|
+
VERSION = '0.10.0'
|
38
16
|
end
|
39
17
|
|
40
18
|
require 'flor/colours'
|
19
|
+
require 'flor/djan'
|
41
20
|
|
21
|
+
require 'flor/id'
|
42
22
|
require 'flor/log'
|
43
23
|
require 'flor/flor'
|
24
|
+
require 'flor/deep'
|
44
25
|
require 'flor/dollar'
|
45
26
|
require 'flor/errors'
|
46
27
|
require 'flor/parser'
|
47
28
|
require 'flor/conf'
|
29
|
+
require 'flor/changes'
|
48
30
|
require 'flor/to_string'
|
49
31
|
|
50
32
|
require 'flor/core'
|
data/lib/flor/changes.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
module Flor::Changes
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def apply(h, cs)
|
6
|
+
|
7
|
+
#return cs if cs.is_a?(Hash)
|
8
|
+
|
9
|
+
h = Flor.dup(h)
|
10
|
+
cs.each { |c| do_apply(h, c) }
|
11
|
+
|
12
|
+
h
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
def do_apply(h, c)
|
18
|
+
|
19
|
+
case c['op']
|
20
|
+
when 'add' then Flor.deep_insert(h, c['path'], c['value'])
|
21
|
+
when 'replace' then Flor.deep_set(h, c['path'], c['value'])
|
22
|
+
when 'remove' then Flor.deep_unset(h, c['path'])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
data/lib/flor/colours.rb
CHANGED
@@ -1,27 +1,3 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#
|
22
|
-
# Made in Japan.
|
23
|
-
#++
|
24
|
-
|
25
1
|
|
26
2
|
module Flor
|
27
3
|
|
@@ -41,8 +17,8 @@ module Flor
|
|
41
17
|
brown yellow purple magenta dark_grey dark_gray light_grey light_gray
|
42
18
|
|
43
19
|
rd red bl blue bu blue ba black bk black gn green gr green dg dark_gray
|
44
|
-
gy light_gray lg light_gray yl yellow ma magenta rs reset
|
45
|
-
un underlined rv reverse bn blink blg bg_light_gray
|
20
|
+
gy light_gray lg light_gray yl yellow y yellow ma magenta rs reset
|
21
|
+
br bright bri bright un underlined rv reverse bn blink blg bg_light_gray
|
46
22
|
und underlined rev reverse
|
47
23
|
]]
|
48
24
|
|
@@ -50,9 +26,13 @@ module Flor
|
|
50
26
|
|
51
27
|
Flor::COLS.each do |k, v|
|
52
28
|
if v.match(/\A\d/)
|
53
|
-
class_eval(
|
29
|
+
class_eval(%{
|
30
|
+
def #{k}(s=nil)
|
31
|
+
s ? "[#{v}m" + s + "[0;9m": "[#{v}m"
|
32
|
+
end })
|
54
33
|
else
|
55
|
-
class_eval(
|
34
|
+
class_eval(
|
35
|
+
"alias #{k} #{v}")
|
56
36
|
end
|
57
37
|
end
|
58
38
|
end
|
@@ -61,7 +41,7 @@ module Flor
|
|
61
41
|
|
62
42
|
Flor::COLS.each do |k, v|
|
63
43
|
if v.match(/\A\d/)
|
64
|
-
class_eval("def #{k}
|
44
|
+
class_eval("def #{k}(s=''); s; end")
|
65
45
|
else
|
66
46
|
class_eval("alias #{k} #{v}")
|
67
47
|
end
|
@@ -78,8 +58,14 @@ module Flor
|
|
78
58
|
|
79
59
|
def self.colours(opts={})
|
80
60
|
|
81
|
-
|
82
|
-
|
61
|
+
c = nil
|
62
|
+
#
|
63
|
+
[ :color, :colour, :colors, :colours ].each do |k|
|
64
|
+
if opts.has_key?(k); c = opts[k]; break; end
|
65
|
+
end
|
66
|
+
|
67
|
+
return @colours if c == true
|
68
|
+
return @no_colours if c == false
|
83
69
|
|
84
70
|
o = opts[:out] || $stdout
|
85
71
|
|
@@ -87,5 +73,53 @@ module Flor
|
|
87
73
|
@colours :
|
88
74
|
@no_colours
|
89
75
|
end
|
76
|
+
|
77
|
+
def self.decolour(s)
|
78
|
+
s.gsub(/\x1b\[\d+(;\d+)?m/, '')
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.no_colour_length(s)
|
82
|
+
|
83
|
+
decolour(s).length
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.truncate_string(s, maxlen, post='...')
|
87
|
+
|
88
|
+
ncl = no_colour_length(s)
|
89
|
+
r = StringIO.new
|
90
|
+
l = 0
|
91
|
+
|
92
|
+
s.scan(/(\x1b\[\d+(?:;\d+)?m|[^\x1b]+)/) do |ss, _|
|
93
|
+
if ss[0, 1] == ""
|
94
|
+
r << ss
|
95
|
+
else
|
96
|
+
#p({ r: r.string, l: l, ssl: ss.length, maxlen: maxlen, reml: maxlen - l })
|
97
|
+
ss = ss[0, maxlen - l]
|
98
|
+
r << ss
|
99
|
+
l += ss.length
|
100
|
+
break if l >= maxlen
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
return r.string if l < maxlen
|
105
|
+
|
106
|
+
if post.is_a?(String)
|
107
|
+
r << post
|
108
|
+
elsif post.is_a?(Proc)
|
109
|
+
r << post.call(ncl, maxlen, s)
|
110
|
+
end
|
111
|
+
|
112
|
+
r.string
|
113
|
+
end
|
114
|
+
|
115
|
+
class << self
|
116
|
+
|
117
|
+
alias decolor decolour
|
118
|
+
|
119
|
+
alias bw_length no_colour_length
|
120
|
+
alias nocolor_length no_colour_length
|
121
|
+
alias no_color_length no_colour_length
|
122
|
+
alias nocolour_length no_colour_length
|
123
|
+
end
|
90
124
|
end
|
91
125
|
|
data/lib/flor/conf.rb
CHANGED
@@ -1,55 +1,100 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#
|
22
|
-
# Made in Japan.
|
23
|
-
#++
|
24
|
-
|
25
1
|
|
26
2
|
module Flor
|
27
3
|
|
28
4
|
module Conf
|
29
5
|
|
30
|
-
#
|
31
6
|
# * uni_ unit prefix (or no prefix like for :env)
|
32
7
|
# * sch_ scheduler prefix
|
33
8
|
# * sto_ storage prefix
|
34
9
|
# * exe_ executor prefix
|
35
10
|
# * log_ logger prefix
|
11
|
+
# * loa_ loader prefix
|
12
|
+
# * gan_ ganger prefix
|
13
|
+
# * (tas_ tasker prefix)
|
14
|
+
#
|
36
15
|
#
|
16
|
+
# * :uni_name
|
17
|
+
# The name for the unit (Scheduler+Storage) pair.
|
18
|
+
# The name must match the following regex: `/\A[a-zA-Z0-9_]+\z/`
|
19
|
+
# Can also be set via the FLOR_UNIT environment variable.
|
37
20
|
#
|
38
21
|
# * :sch_heart_rate
|
39
|
-
#
|
40
|
-
#
|
22
|
+
# Defaults to 0.3s, every 0.3s the scheduler checks its @wake_up and
|
23
|
+
# @next_time fields to determine if it has to run (no db query)
|
24
|
+
# @wake_up is set to true when there are incoming messages give to
|
25
|
+
# this unit, @next_time simply holds the timestamp for the next timer
|
26
|
+
# that has to trigger
|
41
27
|
#
|
42
|
-
# * :
|
43
|
-
# resync
|
28
|
+
# * :sch_reload_after
|
29
|
+
# reload/resync with db after how much time? (defaults to 60 (seconds))
|
30
|
+
# minimizes communication with db in idle periods
|
44
31
|
#
|
45
32
|
# * :sch_max_executors
|
46
|
-
#
|
33
|
+
# How many executor thread at most? (defaults to 7, 1 is OK in certain
|
47
34
|
# environments)
|
48
35
|
#
|
49
36
|
# * :exe_max_messages
|
50
|
-
#
|
51
|
-
# (before quitting and passing the hand)
|
37
|
+
# How many messages will an executor run in a single session
|
38
|
+
# (before quitting and passing the hand) Defaults to 77
|
39
|
+
# An executor will not run indefinitely as long as they are messages.
|
40
|
+
# The goal is to prevent an execution from monopolizing an executor.
|
41
|
+
#
|
42
|
+
# * :sch_msg_max_res_time
|
43
|
+
# Should an executor fail, its reserved messages may stay put.
|
44
|
+
# Each time the scheduler goes to the database to trigger messages,
|
45
|
+
# it first updates messages that have been "reserved" for too long
|
46
|
+
# and sets them back as "created" so that they may be picked again.
|
47
|
+
# This values defaults to 10 * 60 seconds. After 10 minutes in the
|
48
|
+
# "reserved" state, messages are put back in the "created" state
|
49
|
+
# (by a running unit (scheduler) if any).
|
50
|
+
#
|
51
|
+
# And finally:
|
52
|
+
#
|
53
|
+
# * :flor_debug or :debug
|
52
54
|
#
|
55
|
+
# Usually set via the FLOR_DEBUG environment variable.
|
56
|
+
# * `msg` displays the flor messages in a summary, colored format
|
57
|
+
# * `err` displays errors with details, when and if they happen
|
58
|
+
# * `src` displays the source before it gets parsed and launched
|
59
|
+
# * `tree` displays the syntax tree as parsed from the source, right
|
60
|
+
# before launch
|
61
|
+
# * `run` shows info about each [run](doc/glossary.md#run) that just ended
|
62
|
+
# * `sto` displays debug information about the
|
63
|
+
# [storage](doc/glossary.md#storage), it's mostly SQL statements
|
64
|
+
#
|
65
|
+
# * `stdout` states that the debug messages must go to STDOUT
|
66
|
+
# * `stderr` states that the debug messages must go to STDERR
|
67
|
+
#
|
68
|
+
# For example `debug: 'msg,stdout'`
|
69
|
+
|
70
|
+
def self.read(s)
|
71
|
+
|
72
|
+
h = {}
|
73
|
+
h.merge!(Flor::ConfExecutor.interpret(s))
|
74
|
+
h.merge!(interpret_flor_debug(h['flor_debug'] || h['debug']))
|
75
|
+
|
76
|
+
h
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.read_env
|
80
|
+
|
81
|
+
h = {}
|
82
|
+
h.merge!(interpret_env)
|
83
|
+
h.merge!(interpret_flor_debug(ENV['FLOR_DEBUG']))
|
84
|
+
|
85
|
+
h
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.get_class(conf, key)
|
89
|
+
|
90
|
+
if v = conf[key]
|
91
|
+
Kernel.const_get(v)
|
92
|
+
else
|
93
|
+
nil
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
protected # somehow
|
53
98
|
|
54
99
|
LOG_DBG_KEYS = %w[ dbg msg err src tree tree_rw run ]
|
55
100
|
LOG_ALL_KEYS = %w[ all log sto ] + LOG_DBG_KEYS
|
@@ -75,34 +120,19 @@ module Flor
|
|
75
120
|
if a.include?('colours') || a.include?('colors')
|
76
121
|
# LOG_DEBUG=colours forces colors
|
77
122
|
|
78
|
-
if
|
79
|
-
|
80
|
-
elsif a.include?('stderr')
|
81
|
-
h['log_out'] = 'stderr'
|
82
|
-
end
|
123
|
+
h['log_out'] = 'stdout' if h.delete('stdout')
|
124
|
+
h['log_out'] = 'stderr' if h.delete('stderr')
|
83
125
|
|
84
126
|
h
|
85
127
|
end
|
86
128
|
|
87
|
-
def self.
|
88
|
-
|
89
|
-
h = Flor::ConfExecutor.interpret(s)
|
129
|
+
def self.interpret_env
|
90
130
|
|
91
|
-
h
|
92
|
-
|
131
|
+
h = {}
|
132
|
+
u = ENV['FLOR_UNIT']
|
133
|
+
h['unit'] = u if u
|
93
134
|
|
94
|
-
|
95
|
-
|
96
|
-
interpret_flor_debug(ENV['FLOR_DEBUG'])
|
97
|
-
end
|
98
|
-
|
99
|
-
def self.get_class(conf, key)
|
100
|
-
|
101
|
-
if v = conf[key]
|
102
|
-
Kernel.const_get(v)
|
103
|
-
else
|
104
|
-
nil
|
105
|
-
end
|
135
|
+
h
|
106
136
|
end
|
107
137
|
end
|
108
138
|
end
|