Module: AWS::Flow

Included in:
Runner
Defined in:
lib/aws/runner.rb,
lib/aws/flow/fiber.rb,
lib/aws/flow/tasks.rb,
lib/aws/flow/future.rb,
lib/aws/decider/worker.rb,
lib/aws/decider/decider.rb,
lib/aws/decider/options.rb,
lib/aws/decider/version.rb,
lib/aws/flow/flow_utils.rb,
lib/aws/flow/simple_dfa.rb,
lib/aws/decider/activity.rb,
lib/aws/decider/executor.rb,
lib/aws/flow/async_scope.rb,
lib/aws/decider/utilities.rb,
lib/aws/decider/exceptions.rb,
lib/aws/decider/task_poller.rb,
lib/aws/flow/implementation.rb,
lib/aws/decider/task_handler.rb,
lib/aws/flow/async_backtrace.rb,
lib/aws/decider/async_decider.rb,
lib/aws/decider/flow_defaults.rb,
lib/aws/decider/data_converter.rb,
lib/aws/decider/generic_client.rb,
lib/aws/decider/history_helper.rb,
lib/aws/decider/implementation.rb,
lib/aws/decider/state_machines.rb,
lib/aws/decider/workflow_clock.rb,
lib/aws/decider/workflow_client.rb,
lib/aws/decider/decision_context.rb,
lib/aws/decider/workflow_enabled.rb,
lib/aws/flow/begin_rescue_ensure.rb,
lib/aws/decider/activity_definition.rb,
lib/aws/decider/workflow_definition.rb,
lib/aws/decider/async_retrying_executor.rb,
lib/aws/decider/workflow_definition_factory.rb

Defined Under Namespace

Modules: Activities, Activity, Core, Decider, DecisionStateMachineDFA, GenericTypeModule, Runner, Utilities, Workflows Classes: ActivityClient, ActivityDecisionStateMachine, ActivityDefaults, ActivityDefinition, ActivityExecutionContext, ActivityFailureException, ActivityMetadata, ActivityOptions, ActivityRegistrationDefaults, ActivityRegistrationOptions, ActivityRuntimeOptions, ActivityTaskFailedException, ActivityTaskPoller, ActivityTaskTimedOutException, ActivityType, ActivityWorker, AsyncDecider, AsyncRetryingExecutor, ChildWorkflowDecisionStateMachine, ChildWorkflowException, ChildWorkflowFailedException, ChildWorkflowTerminatedException, ChildWorkflowTimedOutException, CompleteWorkflowStateMachine, ContinueAsNewOptions, DecisionContext, DecisionException, DecisionHelper, DecisionID, DecisionStateMachineBase, DecisionTaskHandler, DecisionWrapper, Defaults, EventsIterator, ExponentialRetryOptions, FailWorkflowExecutionException, FlowConstants, FlowException, ForkingExecutor, GenericActivityClient, GenericClient, GenericType, GenericWorker, GenericWorkflowClient, HistoryHelper, LogMock, MethodPair, MinimalDomain, MinimalWorkflowExecution, NoInput, OpenRequestInfo, Options, RejectedExecutionException, RetryDefaults, RetryOptions, RetryPolicy, ScheduleActivityTaskFailedException, SignalDecisionStateMachine, SignalExternalWorkflowException, SignalWorkflowOptions, SingleDecisionData, SingleDecisionIterator, StartChildWorkflowFailedException, StartTimerFailedException, StartWorkflowOptions, SuspendableSemaphore, TimerDecisionStateMachine, WorkerDefaults, WorkerOptions, WorkflowClient, WorkflowClock, WorkflowContext, WorkflowDefaults, WorkflowDefinition, WorkflowDefinitionFactory, WorkflowException, WorkflowFactory, WorkflowFuture, WorkflowOptions, WorkflowRegistrationDefaults, WorkflowRegistrationOptions, WorkflowTaskPoller, WorkflowType, WorkflowWorker, YAMLDataConverter

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.decision_contextObject



63
64
65
# File 'lib/aws/decider/implementation.rb', line 63

def decision_context
  FlowFiber.current[:decision_context]
end

.versionObject



18
19
20
# File 'lib/aws/decider/version.rb', line 18

def self.version
  "2.0.0"
end

.with_retry(options = {}, &block) ⇒ Object

Execute a block with retries within a workflow context.

Parameters:

  • options (defaults to: {})

    The RetryOptions to use.

  • block

    The block to execute.



53
54
55
56
57
58
59
60
61
# File 'lib/aws/decider/implementation.rb', line 53

def with_retry(options = {}, &block)
  # TODO raise a specific error instead of a runtime error
  raise "with_retry can only be used inside a workflow context!" if Utilities::is_external
  retry_options = ExponentialRetryOptions.new(options)
  retry_policy = RetryPolicy.new(retry_options.retry_function, retry_options)
  async_retrying_executor = AsyncRetryingExecutor.new(retry_policy, self.decision_context.workflow_clock, retry_options.return_on_start)
  future = async_retrying_executor.execute(lambda { block.call })
  Utilities::drill_on_future(future) unless retry_options.return_on_start
end

.workflow_client(service = nil, domain = nil, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/aws/decider/implementation.rb', line 72

def self.workflow_client(service = nil, domain = nil, &block)
  options = Utilities::interpret_block_for_options(StartWorkflowOptions, block)
  if ! Utilities::is_external
    service = AWS::SimpleWorkflow.new
    # So, we probably shouldn't be doing this, but we need to slightly
    # redesign where this is available from.
    domain = FlowFiber.current[:decision_context].workflow_context.decision_task.workflow_execution.domain
  else
    if service.nil? || domain.nil?
      raise "You must provide both a service and domain when using workflow client in an external setting"
    end
  end

  workflow_class_name = options.from_class || options.workflow_name
  workflow_class = get_const(workflow_class_name) rescue nil
  WorkflowClient.new(service, domain, workflow_class, options)
end

Instance Method Details

#workflow_client(service = nil, domain = nil, &block) ⇒ Object

Creates a new WorkflowClient instance.

Parameters:

  • service (defaults to: nil)

    An Amazon SWF service reference. This is usually created with:

    swf = AWS::SimpleWorkflow.new
    
  • domain (defaults to: nil)

    The Amazon SWF Domain to use for this workflow client. This is usually created on the service object, such as:

    domain = swf.domains.create('my-domain', 10)
    

    or retrieved from it (for existing domains):

    domain = swf.domains['my-domain']
    
  • block (Hash, StartWorkflowOptions)

    A hash of options to start the workflow.



40
41
42
# File 'lib/aws/decider/implementation.rb', line 40

def workflow_client(service = nil, domain = nil, &block)
  AWS::Flow.send(:workflow_client, service, domain, &block)
end

#workflow_factory(client, domain, &options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method is for internal use only and may be changed or removed

without prior notice.  Use {#workflow_client} instead.


21
22
23
# File 'lib/aws/decider/workflow_enabled.rb', line 21

def workflow_factory(client, domain, &options)
  WorkflowFactory.new(client, domain,  options)
end