Module: Temporal::Saga::Concern

Defined in:
lib/temporal/saga/concern.rb

Instance Method Summary collapse

Instance Method Details

#run_saga(&block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/temporal/saga/concern.rb', line 7

def run_saga(&block)
  saga = Temporal::Saga::Saga.new(workflow)

  block.call(saga)

  Result.new(true)
rescue StandardError => error # TODO: is there a need for a specialized error here?
  logger.error("Saga execution aborted", { error: error.inspect })
  logger.debug(error.backtrace.join("\n"))

  saga.compensate

  Result.new(false, error)
end