Class: Cadence::Workflow

Inherits:
Object
  • Object
show all
Extended by:
Concerns::Executable, Testing::WorkflowOverride, ConvenienceMethods
Defined in:
lib/cadence/workflow.rb,
lib/cadence/workflow/future.rb,
lib/cadence/workflow/poller.rb,
lib/cadence/workflow/context.rb,
lib/cadence/workflow/history.rb,
lib/cadence/workflow/decision.rb,
lib/cadence/workflow/executor.rb,
lib/cadence/workflow/dispatcher.rb,
lib/cadence/workflow/serializer.rb,
lib/cadence/workflow/history/event.rb,
lib/cadence/workflow/state_manager.rb,
lib/cadence/workflow/execution_info.rb,
lib/cadence/workflow/history/window.rb,
lib/cadence/workflow/serializer/base.rb,
lib/cadence/workflow/convenience_methods.rb,
lib/cadence/workflow/replay_aware_logger.rb,
lib/cadence/workflow/history/event_target.rb,
lib/cadence/workflow/decision_state_machine.rb,
lib/cadence/workflow/serializer/start_timer.rb,
lib/cadence/workflow/decision_task_processor.rb,
lib/cadence/workflow/serializer/cancel_timer.rb,
lib/cadence/workflow/serializer/fail_workflow.rb,
lib/cadence/workflow/serializer/record_marker.rb,
lib/cadence/workflow/serializer/complete_workflow.rb,
lib/cadence/workflow/serializer/schedule_activity.rb,
lib/cadence/workflow/serializer/start_child_workflow.rb,
lib/cadence/workflow/serializer/request_activity_cancellation.rb

Defined Under Namespace

Modules: ConvenienceMethods, Decision, Serializer Classes: Context, DecisionStateMachine, DecisionTaskProcessor, Dispatcher, ExecutionInfo, Executor, Future, History, Poller, ReplayAwareLogger, StateManager

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Concerns::Executable

domain, headers, retry_policy, task_list, timeouts

Methods included from ConvenienceMethods

execute!

Methods included from Testing::WorkflowOverride

allow_all_releases, allow_release, disable_release, disabled_releases, execute_locally

Constructor Details

#initialize(context) ⇒ Workflow

Returns a new instance of Workflow.



24
25
26
# File 'lib/cadence/workflow.rb', line 24

def initialize(context)
  @context = context
end

Class Method Details

.execute_in_context(context, input) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cadence/workflow.rb', line 10

def self.execute_in_context(context, input)
  Cadence::ThreadLocalContext.set(context)

  workflow = new(context)
  result = workflow.execute(*input)

  context.complete(result)
rescue StandardError, ScriptError => error
  Cadence.logger.error("Workflow execution failed with: #{error.inspect}")
  Cadence.logger.debug(error.backtrace.join("\n"))

  context.fail(error.class.name, error.message)
end

Instance Method Details

#executeObject

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/cadence/workflow.rb', line 28

def execute
  raise NotImplementedError, '#execute method must be implemented by a subclass'
end