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

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

Overview

This DecisionTaskProvider loads the decision task directly from the SimpleWorkflowService

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DecisionTaskProvider

#get_decision_task, #truncate_history

Constructor Details

#initialize(options = {}) ⇒ ServiceDecisionTaskProvider

Returns a new instance of ServiceDecisionTaskProvider.

Raises:

  • (ArgumentError)


68
69
70
71
72
73
74
# File 'lib/aws/replayer.rb', line 68

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

#domainObject (readonly)

Returns the value of attribute domain.



66
67
68
# File 'lib/aws/replayer.rb', line 66

def domain
  @domain
end

#executionObject (readonly)

Returns the value of attribute execution.



66
67
68
# File 'lib/aws/replayer.rb', line 66

def execution
  @execution
end

#swfObject (readonly)

Returns the value of attribute swf.



66
67
68
# File 'lib/aws/replayer.rb', line 66

def swf
  @swf
end

Instance Method Details

#get_execution_infoObject

This method calls the service to get the workflow execution information



104
105
106
107
108
109
110
# File 'lib/aws/replayer.rb', line 104

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

#get_historyObject



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/aws/replayer.rb', line 76

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

#get_history_page(page_token = nil) ⇒ Object

This method calls the service to fetch a page of workflow history



91
92
93
94
95
96
97
98
99
100
# File 'lib/aws/replayer.rb', line 91

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