Class: Flor::TransientExecutor
- Defined in:
- lib/flor/core/texecutor.rb
Direct Known Subclasses
Defined Under Namespace
Classes: TransientLogger, TransientUnit
Instance Attribute Summary
Attributes inherited from Executor
#execution, #hooks, #traps, #unit
Instance Method Summary collapse
- #archive ⇒ Object
-
#clone ⇒ Object
Used in specs when testing multiple message arrival order on a “suite” of transient executors.
-
#initialize(conf = {}) ⇒ TransientExecutor
constructor
A new instance of TransientExecutor.
- #journal ⇒ Object
- #launch(tree, opts = {}) ⇒ Object
- #step(message) ⇒ Object
- #walk(messages, opts = {}) ⇒ Object
Methods inherited from Executor
#conf, #counter, #counter_add, #counter_next, #exid, #node, #traps_and_hooks, #trigger_block, #trigger_hook, #trigger_trap, #vars
Constructor Details
#initialize(conf = {}) ⇒ TransientExecutor
Returns a new instance of TransientExecutor.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/flor/core/texecutor.rb', line 84 def initialize(conf={}) conf = Flor::Conf.prepare(conf, {}) super( TransientUnit.new(conf), [], # no hooks [], # no traps { 'exid' => Flor.generate_exid('eval', 'u0'), 'nodes' => {}, 'counters' => {}, 'start' => Flor.tstamp }) @unit.archive = {} if conf['archive'] end |
Instance Method Details
#archive ⇒ Object
101 |
# File 'lib/flor/core/texecutor.rb', line 101 def archive; @unit.archive[exid]; end |
#clone ⇒ Object
Used in specs when testing multiple message arrival order on a “suite” of transient executors
163 164 165 166 167 168 169 170 171 172 |
# File 'lib/flor/core/texecutor.rb', line 163 def clone c = TransientExecutor.allocate c.instance_variable_set(:@unit, @unit) c.instance_variable_set(:@traps, []) # not useful for a TransientEx clone c.instance_variable_set(:@execution, Flor.dup(@execution)) c end |
#journal ⇒ Object
100 |
# File 'lib/flor/core/texecutor.rb', line 100 def journal; @unit.journal; end |
#launch(tree, opts = {}) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/flor/core/texecutor.rb', line 103 def launch(tree, opts={}) @unit.opts = opts @unit.archive ||= {} if opts[:archive] @unit.logger.log_src(tree, opts) = [ Flor.make_launch_msg(@execution['exid'], tree, opts) ] @unit.logger.log_tree(.first['tree'], '0', opts) walk(, opts) end |
#step(message) ⇒ Object
155 156 157 158 |
# File 'lib/flor/core/texecutor.rb', line 155 def step() process() end |
#walk(messages, opts = {}) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/flor/core/texecutor.rb', line 117 def walk(, opts={}) loop do = .shift return nil unless if ['point'] == 'terminated' && .any? # # try to handle 'terminated' last # << = .shift end msgs = process() .concat(msgs) return \ if (, opts[:until_after]) return \ if (, opts[:until]) # # Walk is suspended if options :until_after or :until # are satisfied. # Returns the remaining messages. return \ if ['point'] == 'terminated' return \ if ['point'] == 'failed' && ['on_error'] == nil # # Walk exits when execution terminates or fails (without on_error). # Returns the last message end end |