class AWS::Flow::DecisionHelper

A decision helper for a workflow.

@!attribute [Hash] activity_options

@!attribute [Hash] activity_scheduling_event_id_to_activity_id

@!attribute [Hash] decision_map

@!attribute [Hash] scheduled_activities

@!attribute [Hash] scheduled_external_workflows

@!attribute [Hash] scheduled_signals

@!attribute [Hash] scheduled_timers

@!attribute [Hash] signal_initiated_event_to_signal_id

@api private

Attributes

completion_events[R]
force_immediate_decision_timer[R]
maximum_decisions_per_completion[R]
activity_options[RW]
activity_scheduling_event_id_to_activity_id[RW]
child_initiated_event_id_to_workflow_id[RW]
decision_map[RW]
scheduled_activities[RW]
scheduled_external_workflows[RW]
scheduled_signals[RW]
scheduled_timers[RW]
signal_initiated_event_to_signal_id[RW]
workflow_context_data[RW]

Public Class Methods

new() click to toggle source

Creates a new, empty {DecisionHelper} instance.

# File lib/aws/decider/async_decider.rb, line 113
def initialize
  @decision_map = {}
  @id = Hash.new {|hash, key| hash[key] = 0 }
  @scheduled_signals = {}
  @activity_scheduling_event_id_to_activity_id = {}
  @scheduled_activities = {}
  @scheduled_external_workflows = {}
  @scheduled_timers = {}
  @activity_options = {}
  @signal_initiated_event_to_signal_id = {}
  @child_initiated_event_id_to_workflow_id = {}
end

Public Instance Methods

get_activity_id(scheduled_id) click to toggle source

Returns the activity ID for a scheduled activity.

@param [String] scheduled_id

The scheduled activity ID.

@api private

# File lib/aws/decider/async_decider.rb, line 182
def get_activity_id(scheduled_id)
  activity_scheduling_event_id_to_activity_id[scheduled_id]
end
get_next_id(decision_target) click to toggle source

@api private

# File lib/aws/decider/async_decider.rb, line 127
def get_next_id(decision_target)
  id = (@id[decision_target] += 1)
  "#{decision_target}#{id}"
end
get_next_state_machine_which_will_schedule(list) click to toggle source

@api private

# File lib/aws/decider/async_decider.rb, line 133
def get_next_state_machine_which_will_schedule(list)
  return if list.empty?
  ele = list.shift
  ele = list.shift until (list.empty? || ele.get_decision != nil)
  ele
end
handle_decision_task_started_event() click to toggle source

@api private

# File lib/aws/decider/async_decider.rb, line 145
def handle_decision_task_started_event
  # In order to ensure that the events we have already scheduled do not
  # make a decision, we will process only maximum_decisions_per_completion
  # here.
  count = 0
  decision_list = @decision_map.values
  decision_state_machine = get_next_state_machine_which_will_schedule(decision_list)
  until decision_state_machine.nil?
    next_decision_state_machine = get_next_state_machine_which_will_schedule(decision_list)
    count += 1
    if (count == DecisionHelper.maximum_decisions_per_completion &&
        next_decision_state_machine != nil &&
        ! is_completion_event(next_decision_state_machine))
      break
    end
    decision_state_machine.consume(:handle_decision_task_started_event)
    decision_state_machine = next_decision_state_machine
  end
  if (next_decision_state_machine != nil &&
      count < DecisionHelper.maximum_decisions_per_completion)
    next_decision_state_machine.consume(:handle_decision_task_started_event)
  end
end
is_completion_event(decision) click to toggle source
# File lib/aws/decider/async_decider.rb, line 140
def is_completion_event(decision)
  DecisionHelper.completion_events.include? decision.get_decision[:decision_type].to_sym
end
method_missing(method_name, *args) click to toggle source

@api private

# File lib/aws/decider/async_decider.rb, line 170
def method_missing(method_name, *args)
  if [:[]=, :[]].include? method_name
    @decision_map.send(method_name, *args)
  end
end