Class: CMDx::Runtime
- Inherits:
-
Object
- Object
- CMDx::Runtime
- Defined in:
- lib/cmdx/runtime.rb
Overview
Always used via the class method; never new Runtime manually.
Orchestrates a task's full lifecycle: chain acquisition, middlewares,
telemetry, deprecation, callbacks, input resolution, work (wrapped in
retry), output verification, rollback on failure, result finalization,
and teardown (freeze + chain clear).
Signal propagation: work and the surrounding middleware/callback chain
both run inside catch(Signal::TAG), so success! / skip! / fail! /
throw! halt cleanly from anywhere. Raised Faults become echoed signals
(with the upstream result as :origin); other StandardErrors become
failed signals (with the exception as :cause). In strict mode,
execute! re-raises from ensure using a Fault built from the
deepest originating result, so fault.task points at the leaf that
failed.
Class Method Summary collapse
-
.execute(task, strict: false) ⇒ Result
The finalized, frozen result.
Instance Method Summary collapse
-
#execute ⇒ Result
Runs the full lifecycle.
-
#initialize(task, strict: false) ⇒ Runtime
constructor
A new instance of Runtime.
Constructor Details
#initialize(task, strict: false) ⇒ Runtime
Returns a new instance of Runtime.
37 38 39 40 |
# File 'lib/cmdx/runtime.rb', line 37 def initialize(task, strict: false) @task = task @strict = strict end |
Class Method Details
.execute(task, strict: false) ⇒ Result
Returns the finalized, frozen result.
29 30 31 |
# File 'lib/cmdx/runtime.rb', line 29 def execute(task, strict: false) new(task, strict:).execute end |
Instance Method Details
#execute ⇒ Result
Runs the full lifecycle. Teardown runs in ensure, guaranteeing the
task's context/errors get frozen and the fiber chain is cleared even
when strict mode re-raises.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cmdx/runtime.rb', line 48 def execute acquire_chain run_middlewares do emit_telemetry(:task_started) run_deprecation run_lifecycle end finalize_result ensure run_teardown raise_signal! end |