Class: Roast::Workflow::WorkflowExecutor
- Inherits:
-
Object
- Object
- Roast::Workflow::WorkflowExecutor
- Defined in:
- lib/roast/workflow/workflow_executor.rb
Overview
Handles the execution of workflow steps, including orchestration and threading
This class now delegates all step execution to StepExecutorCoordinator, which handles type resolution and execution for all step types. The circular dependency between executors and workflow has been broken by introducing the StepRunner interface.
Defined Under Namespace
Classes: ConfigurationError, InterpolationError, StateError, StepExecutionError, StepNotFoundError, WorkflowExecutorError
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#state_manager ⇒ Object
readonly
Returns the value of attribute state_manager.
-
#step_executor_coordinator ⇒ Object
readonly
Returns the value of attribute step_executor_coordinator.
-
#step_loader ⇒ Object
readonly
Returns the value of attribute step_loader.
Instance Method Summary collapse
- #error(message) ⇒ Object
- #execute_step(name, exit_on_error: true, is_last_step: nil) ⇒ Object
- #execute_steps(workflow_steps) ⇒ Object
-
#initialize(workflow, config_hash, context_path, error_handler: nil, step_loader: nil, command_executor: nil, interpolator: nil, state_manager: nil, iteration_executor: nil, conditional_executor: nil, step_executor_coordinator: nil, phase: :steps) ⇒ WorkflowExecutor
constructor
Initialize a new WorkflowExecutor.
- #interpolate(text) ⇒ Object
-
#log_error(message) ⇒ Object
Logger interface methods for backward compatibility.
- #log_warning(message) ⇒ Object
- #warn(message) ⇒ Object
Constructor Details
#initialize(workflow, config_hash, context_path, error_handler: nil, step_loader: nil, command_executor: nil, interpolator: nil, state_manager: nil, iteration_executor: nil, conditional_executor: nil, step_executor_coordinator: nil, phase: :steps) ⇒ WorkflowExecutor
Initialize a new WorkflowExecutor
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/roast/workflow/workflow_executor.rb', line 51 def initialize(workflow, config_hash, context_path, error_handler: nil, step_loader: nil, command_executor: nil, interpolator: nil, state_manager: nil, iteration_executor: nil, conditional_executor: nil, step_executor_coordinator: nil, phase: :steps) # Create context object to reduce data clump @context = WorkflowContext.new( workflow: workflow, config_hash: config_hash, context_path: context_path, ) # Dependencies with defaults @error_handler = error_handler || ErrorHandler.new @step_loader = step_loader || StepLoader.new(workflow, config_hash, context_path, phase: phase) @command_executor = command_executor || CommandExecutor.new(logger: @error_handler) @interpolator = interpolator || Interpolator.new(workflow, logger: @error_handler) @state_manager = state_manager || StateManager.new(workflow, logger: @error_handler, storage_type: workflow.storage_type) @iteration_executor = iteration_executor || IterationExecutor.new(workflow, context_path, @state_manager, config_hash) @conditional_executor = conditional_executor || ConditionalExecutor.new(workflow, context_path, @state_manager, self) # Initialize coordinator with dependencies base_coordinator = step_executor_coordinator || StepExecutorCoordinator.new( context: @context, dependencies: { workflow_executor: self, interpolator: @interpolator, command_executor: @command_executor, iteration_executor: @iteration_executor, conditional_executor: @conditional_executor, step_loader: @step_loader, state_manager: @state_manager, error_handler: @error_handler, }, ) # Only wrap with reporting decorator if workflow has token tracking enabled @step_executor_coordinator = if workflow.respond_to?(:context_manager) && workflow.context_manager StepExecutorWithReporting.new(base_coordinator, @context) else base_coordinator end end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
29 30 31 |
# File 'lib/roast/workflow/workflow_executor.rb', line 29 def context @context end |
#state_manager ⇒ Object (readonly)
Returns the value of attribute state_manager.
29 30 31 |
# File 'lib/roast/workflow/workflow_executor.rb', line 29 def state_manager @state_manager end |
#step_executor_coordinator ⇒ Object (readonly)
Returns the value of attribute step_executor_coordinator.
29 30 31 |
# File 'lib/roast/workflow/workflow_executor.rb', line 29 def step_executor_coordinator @step_executor_coordinator end |
#step_loader ⇒ Object (readonly)
Returns the value of attribute step_loader.
29 30 31 |
# File 'lib/roast/workflow/workflow_executor.rb', line 29 def step_loader @step_loader end |
Instance Method Details
#error(message) ⇒ Object
108 109 110 |
# File 'lib/roast/workflow/workflow_executor.rb', line 108 def error() @error_handler.log_error() end |
#execute_step(name, exit_on_error: true, is_last_step: nil) ⇒ Object
120 121 122 123 124 125 126 |
# File 'lib/roast/workflow/workflow_executor.rb', line 120 def execute_step(name, exit_on_error: true, is_last_step: nil) @step_executor_coordinator.execute(name, exit_on_error:, is_last_step:) rescue StepLoader::StepNotFoundError => e raise StepNotFoundError.new(e., step_name: e.step_name, original_error: e.original_error) rescue StepLoader::StepExecutionError => e raise StepExecutionError.new(e., step_name: e.step_name, original_error: e.original_error) end |
#execute_steps(workflow_steps) ⇒ Object
112 113 114 |
# File 'lib/roast/workflow/workflow_executor.rb', line 112 def execute_steps(workflow_steps) @step_executor_coordinator.execute_steps(workflow_steps) end |
#interpolate(text) ⇒ Object
116 117 118 |
# File 'lib/roast/workflow/workflow_executor.rb', line 116 def interpolate(text) @interpolator.interpolate(text) end |
#log_error(message) ⇒ Object
Logger interface methods for backward compatibility
96 97 98 |
# File 'lib/roast/workflow/workflow_executor.rb', line 96 def log_error() @error_handler.log_error() end |
#log_warning(message) ⇒ Object
100 101 102 |
# File 'lib/roast/workflow/workflow_executor.rb', line 100 def log_warning() @error_handler.log_warning() end |
#warn(message) ⇒ Object
104 105 106 |
# File 'lib/roast/workflow/workflow_executor.rb', line 104 def warn() @error_handler.log_warning() end |