class Temporal::Workflow::Executor

Attributes

dispatcher[R]
history[R]
state_manager[R]
workflow_class[R]

Public Class Methods

new(workflow_class, history) click to toggle source
# 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

Public Instance Methods

run() click to toggle source
# 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

Private Instance Methods

execute_workflow(input, metadata) click to toggle source
# File lib/temporal/workflow/executor.rb, line 36
def execute_workflow(input, metadata)
  context = Workflow::Context.new(state_manager, dispatcher, workflow_class, metadata)

  Fiber.new do
    workflow_class.execute_in_context(context, input)
  end.resume
end