Class: AWS::Flow::Replayer::ServiceDecisionTaskProvider

Inherits:
DecisionTaskProvider show all
Defined in:
aws-flow-ruby/aws-flow/lib/aws/replayer.rb

Overview

Loads a decision task directly from the AWS Simple Workflow Service.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from DecisionTaskProvider

#get_decision_task, #truncate_history

Constructor Details

- (ServiceDecisionTaskProvider) initialize(options = {})

Initialize a new ServiceDecisionTaskProvider.

Parameters:

  • options (defaults to: {})

    a hash of options to provide. Entries for :domain and :execution must be present in the hash.

Raises:

  • |ArgumentError| if either :domain or :execution is missing from the options parameter.



129
130
131
132
133
134
135
# File 'aws-flow-ruby/aws-flow/lib/aws/replayer.rb', line 129

def initialize(options = {})
  raise ArgumentError.new("options hash must contain :domain") if options[:domain].nil?
  raise ArgumentError.new("options hash must contain :execution") if options[:execution].nil?
  @execution = options[:execution]
  @domain = options[:domain]
  @swf = AWS::SimpleWorkflow.new.client
end

Instance Attribute Details

- (Object) domain (readonly)

Returns the value of attribute domain



119
120
121
# File 'aws-flow-ruby/aws-flow/lib/aws/replayer.rb', line 119

def domain
  @domain
end

- (Object) execution (readonly)

Returns the value of attribute execution



119
120
121
# File 'aws-flow-ruby/aws-flow/lib/aws/replayer.rb', line 119

def execution
  @execution
end

- (Object) swf (readonly)

Returns the value of attribute swf



119
120
121
# File 'aws-flow-ruby/aws-flow/lib/aws/replayer.rb', line 119

def swf
  @swf
end

Instance Method Details

- (Object) get_execution_info

Call AWS Simple Workflow Service to get workflow execution information.

Returns:

  • the execution information based on the :execution and :domain provided as input to the class constructor.



172
173
174
175
176
177
178
# File 'aws-flow-ruby/aws-flow/lib/aws/replayer.rb', line 172

def get_execution_info
  execution = @swf.describe_workflow_execution(
    domain: @domain,
    execution: @execution
  )
  execution["executionInfo"]
end

- (Object) get_history

Get the complete workflow history.



138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'aws-flow-ruby/aws-flow/lib/aws/replayer.rb', line 138

def get_history
  events = []
  # Get the first page of the workflow history
  page = get_history_page
  page["events"].each { |x| events << x }

  # Get the remaining pages of the workflow history
  until page["nextPageToken"].nil?
    page = get_history_page(page["nextPageToken"])
    page["events"].each { |x| events << x }
  end
  events
end

- (Object) get_history_page(page_token = nil)

Fetches a page of workflow history.

Parameters:

  • page_token (defaults to: nil)

    Optional. A page token used to retrieve a particular page of results.



156
157
158
159
160
161
162
163
164
165
# File 'aws-flow-ruby/aws-flow/lib/aws/replayer.rb', line 156

def get_history_page(page_token = nil)
  # Generate the request options for the service call. Optionally merge
  # next_page_token to the hash if the page_token value is not nil.
  request_opts = {
    domain: @domain,
    execution: @execution,
  }.merge(page_token ? { next_page_token: page_token } : {})

  @swf.get_workflow_execution_history(request_opts)
end