Class: Roast::Workflow::StepExecutorCoordinator
- Inherits:
-
Object
- Object
- Roast::Workflow::StepExecutorCoordinator
- Defined in:
- lib/roast/workflow/step_executor_coordinator.rb
Overview
Coordinates the execution of different types of steps
This class is responsible for routing steps to their appropriate executors based on the step type. It acts as a central dispatcher that determines which execution strategy to use for each step.
Current Architecture:
-
WorkflowExecutor.execute_steps still handles basic routing for backward compatibility
-
This coordinator is used by WorkflowExecutor.execute_step for named steps
-
Some step types (parallel) use the StepExecutorFactory pattern
-
Other step types use direct execution methods
TODO: Future refactoring should move all execution logic from WorkflowExecutor to this coordinator and use the factory pattern consistently for all step types.
Instance Method Summary collapse
-
#execute(step, options = {}) ⇒ Object
Execute a step based on its type.
-
#execute_step(step, options = {}) ⇒ Object
Execute a single step (alias for compatibility).
-
#execute_steps(workflow_steps) ⇒ Object
Execute a list of steps.
-
#initialize(context:, dependencies:) ⇒ StepExecutorCoordinator
constructor
A new instance of StepExecutorCoordinator.
Constructor Details
#initialize(context:, dependencies:) ⇒ StepExecutorCoordinator
Returns a new instance of StepExecutorCoordinator.
20 21 22 23 |
# File 'lib/roast/workflow/step_executor_coordinator.rb', line 20 def initialize(context:, dependencies:) @context = context @dependencies = dependencies end |
Instance Method Details
#execute(step, options = {}) ⇒ Object
Execute a step based on its type
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 |
# File 'lib/roast/workflow/step_executor_coordinator.rb', line 55 def execute(step, = {}) step_type = StepTypeResolver.resolve(step, @context) step_name = StepTypeResolver.extract_name(step) Thread.current[:current_step_name] = step_name if step_name Thread.current[:workflow_metadata] = @context.workflow. case step_type when StepTypeResolver::COMMAND_STEP # Command steps should also go through interpolation execute_string_step(step, ) when StepTypeResolver::AGENT_STEP execute_agent_step(step, ) when StepTypeResolver::GLOB_STEP execute_glob_step(step, ) when StepTypeResolver::ITERATION_STEP execute_iteration_step(step, ) when StepTypeResolver::CONDITIONAL_STEP execute_conditional_step(step, ) when StepTypeResolver::CASE_STEP execute_case_step(step, ) when StepTypeResolver::INPUT_STEP execute_input_step(step, ) when StepTypeResolver::HASH_STEP execute_hash_step(step, ) when StepTypeResolver::PARALLEL_STEP # Use factory for parallel steps executor = StepExecutorFactory.for(step, workflow_executor) executor.execute(step) when StepTypeResolver::STRING_STEP execute_string_step(step, ) else execute_standard_step(step, ) end end |
#execute_step(step, options = {}) ⇒ Object
Execute a single step (alias for compatibility)
47 48 49 |
# File 'lib/roast/workflow/step_executor_coordinator.rb', line 47 def execute_step(step, = {}) execute(step, ) end |
#execute_steps(workflow_steps) ⇒ Object
Execute a list of steps
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/roast/workflow/step_executor_coordinator.rb', line 26 def execute_steps(workflow_steps) workflow_steps.each_with_index do |step, index| is_last_step = (index == workflow_steps.length - 1) case step when Hash execute(step, is_last_step:) when Array execute(step, is_last_step:) when String execute(step, is_last_step:) # Handle pause after string steps if @context.workflow.pause_step_name == step Kernel.binding.irb # rubocop:disable Lint/Debugger end else execute_custom_step(step, is_last_step: is_last_step) end end end |