Class: Fractor::Workflow::ResultBuilder
- Inherits:
-
Object
- Object
- Fractor::Workflow::ResultBuilder
- Defined in:
- lib/fractor/workflow/execution/result_builder.rb
Overview
Builds the final workflow result from completed jobs and context. Responsible for finding the workflow output and creating the result object.
Instance Method Summary collapse
-
#build(start_time, end_time) ⇒ WorkflowResult
Build the workflow result.
-
#initialize(workflow, context, completed_jobs, failed_jobs, trace: nil) ⇒ ResultBuilder
constructor
Initialize the result builder.
Constructor Details
#initialize(workflow, context, completed_jobs, failed_jobs, trace: nil) ⇒ ResultBuilder
Initialize the result builder.
17 18 19 20 21 22 23 |
# File 'lib/fractor/workflow/execution/result_builder.rb', line 17 def initialize(workflow, context, completed_jobs, failed_jobs, trace: nil) @workflow = workflow @context = context @completed_jobs = completed_jobs @failed_jobs = failed_jobs @trace = trace end |
Instance Method Details
#build(start_time, end_time) ⇒ WorkflowResult
Build the workflow result.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fractor/workflow/execution/result_builder.rb', line 30 def build(start_time, end_time) output = find_workflow_output WorkflowResult.new( workflow_name: @workflow.class.workflow_name, output: output, completed_jobs: @completed_jobs.to_a, failed_jobs: @failed_jobs.to_a, execution_time: end_time - start_time, success: @failed_jobs.empty?, trace: @trace, correlation_id: @context.correlation_id, ) end |