Class: Fractor::Workflow::ExecutionStrategy Abstract

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

Overview

This class is abstract.

Subclasses must implement the execute method

Base class for workflow execution strategies. Defines the interface for different execution patterns.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(executor, debug: false) ⇒ ExecutionStrategy

Initialize a new execution strategy.

Parameters:

  • executor (WorkflowExecutor)

    The workflow executor

  • debug (Boolean) (defaults to: false)

    Whether to enable debug logging



16
17
18
19
# File 'lib/fractor/workflow/execution_strategy.rb', line 16

def initialize(executor, debug: false)
  @executor = executor
  @debug = debug
end

Instance Attribute Details

#debugObject (readonly)

Returns the value of attribute debug.



10
11
12
# File 'lib/fractor/workflow/execution_strategy.rb', line 10

def debug
  @debug
end

#executorObject (readonly)

Returns the value of attribute executor.



10
11
12
# File 'lib/fractor/workflow/execution_strategy.rb', line 10

def executor
  @executor
end

Instance Method Details

#execute(job_group) ⇒ Boolean

Execute a group of jobs according to the strategy.

Parameters:

  • job_group (Array<Job>)

    Jobs to execute

Returns:

  • (Boolean)

    true if execution should continue

Raises:



26
27
28
# File 'lib/fractor/workflow/execution_strategy.rb', line 26

def execute(job_group)
  raise NotImplementedError, "#{self.class} must implement #execute"
end

#should_execute_job?(job) ⇒ Boolean

Check if a job should be executed based on its condition.

Parameters:

  • job (Job)

    The job to check

Returns:

  • (Boolean)

    true if the job should execute



34
35
36
37
38
# File 'lib/fractor/workflow/execution_strategy.rb', line 34

def should_execute_job?(job)
  return true unless job.condition_proc

  job.condition_proc.call(executor.context)
end