class Temporal::Workflow
Public Class Methods
execute_in_context(context, input)
click to toggle source
# File lib/temporal/workflow.rb, line 11 def self.execute_in_context(context, input) old_context = Temporal::ThreadLocalContext.get Temporal::ThreadLocalContext.set(context) workflow = new(context) result = workflow.execute(*input) context.complete(result) unless context.completed? rescue StandardError, ScriptError => error Temporal.logger.error("Workflow execution failed", context.metadata.to_h.merge(error: error.inspect)) Temporal.logger.debug(error.backtrace.join("\n")) Temporal::ErrorHandler.handle(error, metadata: context.metadata) context.fail(error) ensure Temporal::ThreadLocalContext.set(old_context) end
new(context)
click to toggle source
# File lib/temporal/workflow.rb, line 30 def initialize(context) @context = context end
Public Instance Methods
execute()
click to toggle source
# File lib/temporal/workflow.rb, line 34 def execute raise NotImplementedError, '#execute method must be implemented by a subclass' end
Private Instance Methods
logger()
click to toggle source
# File lib/temporal/workflow.rb, line 44 def logger workflow.logger end
workflow()
click to toggle source
# File lib/temporal/workflow.rb, line 40 def workflow @context end