Class: AWS::Flow::Replayer::WorkflowReplayer

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

Overview

An AWS Flow Framework utility used to replay a workflow history in the decider against the workflow implementation. Primarily used for debugging workflows.

## Usage

**Create an instance of the replayer with the required options:**

~~~~ replayer = AWS::Flow::Replayer::WorkflowReplayer.new(

domain: '<domain_name>',
execution: {
  workflow_id: "<workflow_id",
  run_id: "<run_id>"
},
workflow_class: WorkflowClass

) ~~~~

**Call the replay method (optionally) with the replay_upto event_id number**

~~~~ decision = replayer.replay(20) ~~~~

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ WorkflowReplayer

Initialize a new WorkflowReplayer.

Parameters:

  • options

    A hash of options. The hash must contain at least ‘:workflow_class`.

Raises:

  • |ArgumentError| if no options hash was passed in, or if the options are missing the ‘:workflow_class` key.



218
219
220
221
222
223
224
225
226
# File 'lib/aws/replayer.rb', line 218

def initialize(options)
  raise ArgumentError.new("You must pass in an options hash") if options.nil?
  raise ArgumentError.new("options hash must contain :workflow_class") if options[:workflow_class].nil?

  # Create the service decision task helper to fetch and truncate the
  # history
  @task_provider = ServiceDecisionTaskProvider.new(options)
  @task_handler = DecisionTaskHandler.from_workflow_class(options[:workflow_class])
end

Instance Attribute Details

#task_handlerObject (readonly)

Returns the value of attribute task_handler.



208
209
210
# File 'lib/aws/replayer.rb', line 208

def task_handler
  @task_handler
end

#task_providerObject (readonly)

Returns the value of attribute task_provider.



208
209
210
# File 'lib/aws/replayer.rb', line 208

def task_provider
  @task_provider
end

Instance Method Details

#replay(replay_upto = nil) ⇒ Object

Performs a replay of workflow history.

Parameters:

  • replay_upto (Fixnum) (defaults to: nil)

    Optional. If set, replays the history only until the specified event is reached. If not set, then all history will be returned.



234
235
236
237
# File 'lib/aws/replayer.rb', line 234

def replay(replay_upto = nil)
  task = @task_provider.get_decision_task(replay_upto)
  @task_handler.handle_decision_task(task) unless task.nil?
end