class AWS::Flow::GenericWorkflowClient

A generic workflow client implementation.

Attributes

data_converter[RW]

The data converter for the generic workflow client.

Public Class Methods

new(decision_helper, workflow_context) click to toggle source

Creates a new generic workflow client.

@param decision_helper

@param workflow_context

# File lib/aws/decider/decider.rb, line 59
def initialize(decision_helper, workflow_context)
  @decision_helper = decision_helper
  @workflow_context = workflow_context
end

Public Instance Methods

completion_function(event, open_request) click to toggle source
# File lib/aws/decider/decider.rb, line 44
def completion_function(event, open_request)
  open_request.result = event.attributes[:result]
  open_request.completion_handle.complete
end
handle_child_workflow_execution_canceled(event) click to toggle source

Handler for the ‘ChildWorkflowExecutionCanceled` event.

@param [Object] event

The event instance.
# File lib/aws/decider/decider.rb, line 78
def handle_child_workflow_execution_canceled(event)
  handle_event(event,
               {
                 :id_methods => [:workflow_execution, :workflow_id],
                 :consume_symbol => :handle_cancellation_event,
                 :decision_helper_scheduled => :scheduled_external_workflows,
                 :handle_open_request => lambda do |event, open_request|
                   cancellation_exception = CancellationException.new("Cancelled from a ChildWorkflowExecutionCancelled")
                   open_request.completion_handle.fail(cancellation_exception)
                 end
               })
end
handle_child_workflow_execution_completed(event) click to toggle source

Handler for the ‘ChildWorkflowExecutionCompleted` event.

@param [Object] event

The event instance.
# File lib/aws/decider/decider.rb, line 97
def handle_child_workflow_execution_completed(event)
  handle_event(event,
               {:id_methods => [:workflow_execution, :workflow_id],
                 :consume_symbol => :handle_completion_event,
                 :decision_helper_scheduled => :scheduled_external_workflows,
                 :handle_open_request => method(:completion_function)
               })
end
handle_child_workflow_execution_failed(event) click to toggle source

Handler for the ‘ChildWorkflowExecutionFailed` event.

@param [Object] event

The event instance.
# File lib/aws/decider/decider.rb, line 111
def handle_child_workflow_execution_failed(event)
  handle_event(event,
               {:id_methods => [:workflow_execution, :workflow_id],
                 :consume_symbol => :handle_completion_event,
                 :decision_helper_scheduled => :scheduled_external_workflows,
                 :handle_open_request => lambda do |event, open_request|
                   attributes = event.attributes
                   reason = attributes[:reason] if attributes.keys.include? :reason
                   reason ||= "The activity which failed did not provide a reason"
                   details = attributes[:details] if attributes.keys.include? :details
                   details ||= "The activity which failed did not provide details"
                   # workflow_id = @decision_helper.child_initiated_event_id_to_workflow_id[event.attributes.initiated_event_id]
                   # @decision_helper.scheduled_external_workflows[workflow_id]
                   failure = ChildWorkflowFailedException.new(event.id, event.attributes[:workflow_execution], event.attributes.workflow_type, reason, details )
                   open_request.completion_handle.fail(failure)
                 end
               }
               )
end
handle_child_workflow_execution_started(event) click to toggle source

Handler for the ‘ChildWorkflowExecutionStarted` event.

@param [Object] event

The event instance.
# File lib/aws/decider/decider.rb, line 137
def handle_child_workflow_execution_started(event)
  handle_event(event,
               {:id_methods => [:workflow_execution, :workflow_id],
                 :consume_symbol => :handle_started_event,
                 :decision_helper_scheduled => :scheduled_external_workflows,
                 :handle_open_request => lambda do |event, open_request|
                   open_request.run_id.set(event.attributes.workflow_execution.run_id)
                 end
               })
end
handle_child_workflow_execution_terminated(event) click to toggle source

Handler for the ‘ChildWorkflowExecutionTerminated` event.

@param [Object] event

The event instance.
# File lib/aws/decider/decider.rb, line 153
def handle_child_workflow_execution_terminated(event)
  handle_event(event,
               {:id_methods => [:workflow_execution, :workflow_id],
                 :consume_symbol => :handle_completion_event,
                 :decision_helper_scheduled => :scheduled_external_workflows,
                 :handle_open_request => lambda do |event, open_request|
                   exception = ChildWorkflowTerminatedException.new(event.id, open_request.description, nil)
                   open_request.completion_handle.fail(exception)
                 end
               })
end
handle_child_workflow_execution_timed_out(event) click to toggle source

Handler for the ‘ChildWorkflowExecutionTimedOut` event.

@param [Object] event

The event instance.
# File lib/aws/decider/decider.rb, line 170
def handle_child_workflow_execution_timed_out(event)
  handle_event(event,
               {:id_methods => [:workflow_execution, :workflow_id],
                 :consume_symbol => :handle_completion_event,
                 :decision_helper_scheduled => :scheduled_external_workflows,
                 :handle_open_request => lambda do |event, open_request|
                   exception = ChildWorkflowTimedOutException.new(event.id, open_request.description, nil)
                   open_request.completion_handle.fail(exception)
                 end
               })
end
handle_external_workflow_execution_cancel_requested(event) click to toggle source

Handler for the ‘ExternalWorkflowExecutionCancelRequested` event.

@param [Object] event

The event instance.
# File lib/aws/decider/decider.rb, line 69
def handle_external_workflow_execution_cancel_requested(event)
  # NOOP
end
handle_external_workflow_execution_signaled(event) click to toggle source

Handler for the ‘ExternalWorkflowExecutionSignaled` event.

@param [Object] event

The event instance.
# File lib/aws/decider/decider.rb, line 187
def handle_external_workflow_execution_signaled(event)
  signal_id = @decision_helper.signal_initiated_event_to_signal_id[event.attributes[:initiated_event_id]]
  state_machine = @decision_helper[signal_id]
  state_machine.consume(:handle_completion_event)
  if state_machine.done?
    open_request = @decision_helper.scheduled_signals.delete(signal_id)
    open_request.result = nil
    open_request.completion_handle.complete
  end
end
handle_signal_external_workflow_execution_failed(event) click to toggle source

Handler for the ‘SignalExternalWorkflowExecutionFailed` event.

@param [Object] event

The event instance.
# File lib/aws/decider/decider.rb, line 203
def handle_signal_external_workflow_execution_failed(event)
  handle_event(event, {
                 :id_methods => [:control],
                 :consume_symbol => :handle_completion_event,
                 :decision_helper_scheduled => :scheduled_signals,
                 :handle_open_request => lambda do |event, open_request|
                   workflow_execution = AWS::Flow::MinimalWorkflowExecution.new("",event.attributes.workflow_id, event.attributes.run_id)
                   failure = SignalExternalWorkflowException(event.id, workflow_execution, event.attributes.cause)
                   open_request.completion_handle.fail(failure)
                 end
               })
end
handle_start_child_workflow_execution_failed(event) click to toggle source

Handler for the ‘StartExternalWorkflowExecutionFailed` event.

@param [Object] event

The event instance.
# File lib/aws/decider/decider.rb, line 221
def handle_start_child_workflow_execution_failed(event)
  handle_event(event, {
               :id_methods => [:workflow_id],
               :consume_symbol => :handle_initiation_failed_event,
               :decision_helper_scheduled => :scheduled_external_workflows,
               :handle_open_request => lambda do |event, open_request|
                   workflow_execution = AWS::Flow::MinimalWorkflowExecution.new("",event.attributes.workflow_id, nil)
                 workflow_type = event.attributes.workflow_type
                 cause = event.attributes.cause
                 failure = StartChildWorkflowFailedException.new(event.id, workflow_execution, workflow_type, cause)
                 open_request.completion_handle.fail(failure)
               end
               })
end