Class: AWS::Flow::DecisionHelper Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/decider/async_decider.rb

Overview

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

A decision helper for a workflow.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDecisionHelper

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.

Creates a new, empty AWS::Flow::DecisionHelper instance.



113
114
115
116
117
118
119
120
121
122
123
124
# 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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ 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.



170
171
172
173
174
# 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

Class Attribute Details

.completion_eventsObject (readonly)

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.



106
107
108
# File 'lib/aws/decider/async_decider.rb', line 106

def completion_events
  @completion_events
end

.force_immediate_decision_timerObject (readonly)

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.



106
107
108
# File 'lib/aws/decider/async_decider.rb', line 106

def force_immediate_decision_timer
  @force_immediate_decision_timer
end

.maximum_decisions_per_completionObject (readonly)

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.



106
107
108
# File 'lib/aws/decider/async_decider.rb', line 106

def maximum_decisions_per_completion
  @maximum_decisions_per_completion
end

Instance Attribute Details

#activity_optionsObject

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.



104
105
106
# File 'lib/aws/decider/async_decider.rb', line 104

def activity_options
  @activity_options
end

#activity_scheduling_event_id_to_activity_idObject

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.



104
105
106
# File 'lib/aws/decider/async_decider.rb', line 104

def activity_scheduling_event_id_to_activity_id
  @activity_scheduling_event_id_to_activity_id
end

#child_initiated_event_id_to_workflow_idObject

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.



104
105
106
# File 'lib/aws/decider/async_decider.rb', line 104

def child_initiated_event_id_to_workflow_id
  @child_initiated_event_id_to_workflow_id
end

#decision_mapObject

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.



104
105
106
# File 'lib/aws/decider/async_decider.rb', line 104

def decision_map
  @decision_map
end

#scheduled_activitiesObject

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.



104
105
106
# File 'lib/aws/decider/async_decider.rb', line 104

def scheduled_activities
  @scheduled_activities
end

#scheduled_external_workflowsObject

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.



104
105
106
# File 'lib/aws/decider/async_decider.rb', line 104

def scheduled_external_workflows
  @scheduled_external_workflows
end

#scheduled_signalsObject

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.



104
105
106
# File 'lib/aws/decider/async_decider.rb', line 104

def scheduled_signals
  @scheduled_signals
end

#scheduled_timersObject

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.



104
105
106
# File 'lib/aws/decider/async_decider.rb', line 104

def scheduled_timers
  @scheduled_timers
end

#signal_initiated_event_to_signal_idObject

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.



104
105
106
# File 'lib/aws/decider/async_decider.rb', line 104

def signal_initiated_event_to_signal_id
  @signal_initiated_event_to_signal_id
end

#workflow_context_dataObject

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.



104
105
106
# File 'lib/aws/decider/async_decider.rb', line 104

def workflow_context_data
  @workflow_context_data
end

Instance Method Details

#get_activity_id(scheduled_id) ⇒ 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.

Returns the activity ID for a scheduled activity.

Parameters:

  • scheduled_id (String)

    The scheduled activity ID.



182
183
184
# 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) ⇒ 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.



127
128
129
130
# 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) ⇒ 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.



133
134
135
136
137
138
# 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_eventObject

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.



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# 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) ⇒ 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.



140
141
142
# 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