Class: RubyReactor::Executor::ResultHandler
- Inherits:
-
Object
- Object
- RubyReactor::Executor::ResultHandler
- Defined in:
- lib/ruby_reactor/executor/result_handler.rb
Instance Attribute Summary collapse
-
#step_results ⇒ Object
readonly
Returns the value of attribute step_results.
Instance Method Summary collapse
- #final_result(reactor_class) ⇒ Object
- #handle_execution_error(error) ⇒ Object
- #handle_step_result(step_config, result, resolved_arguments) ⇒ Object
-
#initialize(context:, compensation_manager:, dependency_graph:) ⇒ ResultHandler
constructor
A new instance of ResultHandler.
Constructor Details
#initialize(context:, compensation_manager:, dependency_graph:) ⇒ ResultHandler
Returns a new instance of ResultHandler.
6 7 8 9 10 11 |
# File 'lib/ruby_reactor/executor/result_handler.rb', line 6 def initialize(context:, compensation_manager:, dependency_graph:) @context = context @compensation_manager = compensation_manager @dependency_graph = dependency_graph @step_results = {} end |
Instance Attribute Details
#step_results ⇒ Object (readonly)
Returns the value of attribute step_results.
13 14 15 |
# File 'lib/ruby_reactor/executor/result_handler.rb', line 13 def step_results @step_results end |
Instance Method Details
#final_result(reactor_class) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/ruby_reactor/executor/result_handler.rb', line 48 def final_result(reactor_class) if reactor_class.return_step result_value = @context.get_result(reactor_class.return_step) RubyReactor.Success(result_value) else RubyReactor.Success(@context.intermediate_results) end end |
#handle_execution_error(error) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ruby_reactor/executor/result_handler.rb', line 31 def handle_execution_error(error) case error when Error::StepFailureError handle_step_failure_error(error) when Error::InputValidationError # Preserve validation errors as-is for proper error handling RubyReactor.Failure(error, validation_errors: error.field_errors) when Error::Base # Other errors need rollback @compensation_manager.rollback_completed_steps RubyReactor.Failure("Execution error: #{error.}", exception_class: error.class.name) else # Unknown errors - don't rollback as they may not be reactor-related RubyReactor.Failure("Execution failed: #{error.}", exception_class: error.class.name) end end |
#handle_step_result(step_config, result, resolved_arguments) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ruby_reactor/executor/result_handler.rb', line 15 def handle_step_result(step_config, result, resolved_arguments) case result when RubyReactor::Skipped # Important: must come before the Success branch — Skipped < Success. handle_skipped(step_config, result) when RubyReactor::Success handle_success(step_config, result, resolved_arguments) when RubyReactor::MaxRetriesExhaustedFailure handle_retries_exhausted(step_config, result, resolved_arguments) when RubyReactor::Failure handle_failure(step_config, result, resolved_arguments) else handle_unknown_result(step_config, result, resolved_arguments) end end |