Class: Temporal::Workflow::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/temporal/workflow/executor.rb

Instance Method Summary collapse

Constructor Details

#initialize(workflow_class, history) ⇒ Executor

Returns a new instance of Executor.



11
12
13
14
15
16
# File 'lib/temporal/workflow/executor.rb', line 11

def initialize(workflow_class, history)
  @workflow_class = workflow_class
  @dispatcher = Dispatcher.new
  @state_manager = StateManager.new(dispatcher)
  @history = history
end

Instance Method Details

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/temporal/workflow/executor.rb', line 18

def run
  dispatcher.register_handler(
    History::EventTarget.workflow,
    'started',
    &method(:execute_workflow)
  )

  while window = history.next_window
    state_manager.apply(window)
  end

  return state_manager.commands
end