Class: AWS::Flow::SingleDecisionIterator

Inherits:
Object
  • Object
show all
Defined in:
aws-flow-ruby/aws-flow/lib/aws/decider/history_helper.rb

Class Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (SingleDecisionIterator) initialize(decision_tasks)

Returns a new instance of SingleDecisionIterator



105
106
107
108
109
110
# File 'aws-flow-ruby/aws-flow/lib/aws/decider/history_helper.rb', line 105

def initialize(decision_tasks)
  @events = EventsIterator.new(decision_tasks)
  fill_next
  @current = @next
  fill_next
end

Class Attribute Details

+ (Object) decision_events

Returns the value of attribute decision_events



69
70
71
# File 'aws-flow-ruby/aws-flow/lib/aws/decider/history_helper.rb', line 69

def decision_events
  @decision_events
end

Instance Method Details

- (Object) fill_next



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'aws-flow-ruby/aws-flow/lib/aws/decider/history_helper.rb', line 129

def fill_next
  decision_task_timed_out = false
  decision_start_to_completion_events, decision_completion_to_start_events = [], []
  next_replay_current_time_milliseconds = -1
  last_decision_index = -1
  concurrent_to_decision = true
  while @events.events.length > 0
    event = @events.events.shift
    event_type = event.event_type.to_sym
    case event_type
    when :DecisionTaskCompleted
      #TODO get execution context
      #TODO updateWorkflowContextDataAndComponentVersions
      concurrent_to_decision = false
    when :DecisionTaskStarted
      next_replay_current_time_milliseconds = event.created_at
      if decision_task_timed_out
        @current.decision_events.concat(decision_start_to_completion_events)
        decision_start_to_completion_events = []
        decision_task_timed_out = false
      else
        break
      end
    when :DecisionTaskTimedOut
      decision_task_timed_out = true
    when :DecisionTaskScheduled
      # pass
    when :MarkerRecorded
      # pass
    else
      if concurrent_to_decision
        decision_start_to_completion_events << event
      else
        if is_decision_event? event_type
          last_decision_index = decision_completion_to_start_events.length
        end
        decision_completion_to_start_events << event
      end
    end
  end
  next_events = reorder_events(decision_start_to_completion_events, decision_completion_to_start_events, last_decision_index)
  @next = SingleDecisionData.new(next_events, next_replay_current_time_milliseconds, @workflow_context_data )
end

- (Object) get_decision_task



101
102
103
# File 'aws-flow-ruby/aws-flow/lib/aws/decider/history_helper.rb', line 101

def get_decision_task
  @events.decision_task
end

- (Boolean) is_decision_event?(event)

Returns:

  • (Boolean)


97
98
99
# File 'aws-flow-ruby/aws-flow/lib/aws/decider/history_helper.rb', line 97

def is_decision_event?(event)
  SingleDecisionIterator.decision_events.member? event
end

- (Object) next



112
113
114
115
116
117
# File 'aws-flow-ruby/aws-flow/lib/aws/decider/history_helper.rb', line 112

def next
  result = @current
  @current = @next
  fill_next
  return result
end

- (Object) reorder_events(start_to_completion, completion_to_start, last_decision_index)



119
120
121
122
123
124
125
126
127
# File 'aws-flow-ruby/aws-flow/lib/aws/decider/history_helper.rb', line 119

def reorder_events(start_to_completion, completion_to_start, last_decision_index)
  reordered = []
  reordered.concat(completion_to_start.slice(0, last_decision_index + 1)) if last_decision_index >= 0
  reordered.concat(start_to_completion)
  if completion_to_start.length > last_decision_index + 1
    reordered.concat(completion_to_start.slice((last_decision_index + 1)..-1))
  end
  return reordered.flatten
end