Class: AWS::Flow::GenericWorkflowClient

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

Overview

A generic workflow client implementation.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (GenericWorkflowClient) initialize(decision_helper, workflow_context)

Creates a new generic workflow client.

Parameters:

  • decision_helper
  • workflow_context


59
60
61
62
# File 'aws-flow-ruby/aws-flow/lib/aws/decider/decider.rb', line 59

def initialize(decision_helper, workflow_context)
  @decision_helper = decision_helper
  @workflow_context = workflow_context
end

Instance Attribute Details

- (Object) data_converter

The data converter for the generic workflow client.



51
52
53
# File 'aws-flow-ruby/aws-flow/lib/aws/decider/decider.rb', line 51

def data_converter
  @data_converter
end

Instance Method Details

- (Object) completion_function(event, open_request)



44
45
46
47
# File 'aws-flow-ruby/aws-flow/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

- (Object) handle_child_workflow_execution_canceled(event)

Handler for the ChildWorkflowExecutionCanceled event.

Parameters:

  • event (Object)

    The event instance.



78
79
80
81
82
83
84
85
86
87
88
89
# File 'aws-flow-ruby/aws-flow/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

- (Object) handle_child_workflow_execution_completed(event)

Handler for the ChildWorkflowExecutionCompleted event.

Parameters:

  • event (Object)

    The event instance.



97
98
99
100
101
102
103
104
# File 'aws-flow-ruby/aws-flow/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

- (Object) handle_child_workflow_execution_failed(event)

Handler for the ChildWorkflowExecutionFailed event.

Parameters:

  • event (Object)

    The event instance.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'aws-flow-ruby/aws-flow/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

- (Object) handle_child_workflow_execution_started(event)

Handler for the ChildWorkflowExecutionStarted event.

Parameters:

  • event (Object)

    The event instance.



137
138
139
140
141
142
143
144
145
146
# File 'aws-flow-ruby/aws-flow/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

- (Object) handle_child_workflow_execution_terminated(event)

Handler for the ChildWorkflowExecutionTerminated event.

Parameters:

  • event (Object)

    The event instance.



153
154
155
156
157
158
159
160
161
162
163
# File 'aws-flow-ruby/aws-flow/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

- (Object) handle_child_workflow_execution_timed_out(event)

Handler for the ChildWorkflowExecutionTimedOut event.

Parameters:

  • event (Object)

    The event instance.



170
171
172
173
174
175
176
177
178
179
180
# File 'aws-flow-ruby/aws-flow/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

- (Object) handle_external_workflow_execution_cancel_requested(event)

Handler for the ExternalWorkflowExecutionCancelRequested event.

Parameters:

  • event (Object)

    The event instance.



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

def handle_external_workflow_execution_cancel_requested(event)
  # NOOP
end

- (Object) handle_external_workflow_execution_signaled(event)

Handler for the ExternalWorkflowExecutionSignaled event.

Parameters:

  • event (Object)

    The event instance.



187
188
189
190
191
192
193
194
195
196
# File 'aws-flow-ruby/aws-flow/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

- (Object) handle_signal_external_workflow_execution_failed(event)

Handler for the SignalExternalWorkflowExecutionFailed event.

Parameters:

  • event (Object)

    The event instance.



203
204
205
206
207
208
209
210
211
212
213
214
# File 'aws-flow-ruby/aws-flow/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

- (Object) handle_start_child_workflow_execution_failed(event)

Handler for the StartExternalWorkflowExecutionFailed event.

Parameters:

  • event (Object)

    The event instance.



221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'aws-flow-ruby/aws-flow/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