Class: Fractor::Workflow::WorkflowResult

Inherits:
Object
  • Object
show all
Defined in:
lib/fractor/workflow/workflow_result.rb

Overview

Represents the result of a workflow execution. Contains information about completed jobs, failed jobs, execution time, and output.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workflow_name:, output:, completed_jobs:, failed_jobs:, execution_time:, success:, trace: nil, correlation_id: nil) ⇒ WorkflowResult

Initialize a new workflow result.

Parameters:

  • workflow_name (String)

    The name of the workflow

  • output (Object)

    The workflow output

  • completed_jobs (Array<String>)

    List of completed job names

  • failed_jobs (Array<String>)

    List of failed job names

  • execution_time (Float)

    Execution time in seconds

  • success (Boolean)

    Whether the workflow succeeded

  • trace (ExecutionTrace, nil) (defaults to: nil)

    Optional execution trace

  • correlation_id (String, nil) (defaults to: nil)

    Optional correlation ID



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fractor/workflow/workflow_result.rb', line 21

def initialize(workflow_name:, output:, completed_jobs:, failed_jobs:,
               execution_time:, success:, trace: nil, correlation_id: nil)
  @workflow_name = workflow_name
  @output = output
  @completed_jobs = completed_jobs
  @failed_jobs = failed_jobs
  @execution_time = execution_time
  @success = success
  @trace = trace
  @correlation_id = correlation_id
end

Instance Attribute Details

#completed_jobsObject (readonly)

Returns the value of attribute completed_jobs.



8
9
10
# File 'lib/fractor/workflow/workflow_result.rb', line 8

def completed_jobs
  @completed_jobs
end

#correlation_idObject (readonly)

Returns the value of attribute correlation_id.



8
9
10
# File 'lib/fractor/workflow/workflow_result.rb', line 8

def correlation_id
  @correlation_id
end

#execution_timeObject (readonly)

Returns the value of attribute execution_time.



8
9
10
# File 'lib/fractor/workflow/workflow_result.rb', line 8

def execution_time
  @execution_time
end

#failed_jobsObject (readonly)

Returns the value of attribute failed_jobs.



8
9
10
# File 'lib/fractor/workflow/workflow_result.rb', line 8

def failed_jobs
  @failed_jobs
end

#outputObject (readonly)

Returns the value of attribute output.



8
9
10
# File 'lib/fractor/workflow/workflow_result.rb', line 8

def output
  @output
end

#successObject (readonly)

Returns the value of attribute success.



8
9
10
# File 'lib/fractor/workflow/workflow_result.rb', line 8

def success
  @success
end

#traceObject (readonly)

Returns the value of attribute trace.



8
9
10
# File 'lib/fractor/workflow/workflow_result.rb', line 8

def trace
  @trace
end

#workflow_nameObject (readonly)

Returns the value of attribute workflow_name.



8
9
10
# File 'lib/fractor/workflow/workflow_result.rb', line 8

def workflow_name
  @workflow_name
end

Instance Method Details

#execution_time_msFloat

Get execution time in milliseconds.

Returns:

  • (Float)

    Execution time in milliseconds



50
51
52
# File 'lib/fractor/workflow/workflow_result.rb', line 50

def execution_time_ms
  (@execution_time * 1000).round(2)
end

#failed?Boolean

Check if the workflow failed.

Returns:

  • (Boolean)

    true if failed



43
44
45
# File 'lib/fractor/workflow/workflow_result.rb', line 43

def failed?
  !@success
end

#success?Boolean

Check if the workflow succeeded.

Returns:

  • (Boolean)

    true if successful



36
37
38
# File 'lib/fractor/workflow/workflow_result.rb', line 36

def success?
  @success
end