class AWS::Flow::Replayer::DecisionTaskProvider
Used by {Replayer} to fetch a [DecisionTask][] which will be used by {DecisionTaskHandler}.
[DecisionTask]: docs.aws.amazon.com/AWSRubySDK/latest/AWS/SimpleWorkflow/DecisionTask.html
@abstract Implement the ‘get_history_page` and `get_execution_info` methods to
use it.
Public Instance Methods
Fetches the workflow history and wraps all the history events, workflow type and workflow execution inside a decision task for the decider to work on.
@param replay_upto [Fixnum] Optional. The event_id of the last event
to return. If set, returns the history only until the specified event is reached. If not set, then all available history will be returned. See [HistoryEvent][] for more information. [HistoryEvent]: http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/SimpleWorkflow/HistoryEvent.html
@return [DecisionTask] the workflow history encapsulated in a
[DecisionTask][], optionally truncated to the event ID passed to `replay_upto`. [DecisionTask]: http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/SimpleWorkflow/DecisionTask.html
# File lib/aws/replayer.rb, line 36 def get_decision_task(replay_upto = nil) # Get workflow execution info so that we can populate the workflowType # and execution fields of the [DecisionTask][]. # # [DecisionTask]: http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/SimpleWorkflow/DecisionTask.html # execution_info = get_execution_info events = get_history # Truncate history if replay_upto variable is set so that we only # replay the history till the specified event # events = truncate_history(events, replay_upto) return nil if events.nil? # Generate the hash to instantiate a [DecisionTask][]. We can set # *taskToken* and *nextPageToken* to nil since we don't need the # values in the replayer. # # [DecisionTask]: http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/SimpleWorkflow/DecisionTask.html data = { 'taskToken' => nil, 'workflowExecution' => execution_info["execution"], 'workflowType' => execution_info["workflowType"], 'events' => events, 'nextPageToken' => nil } AWS::SimpleWorkflow::DecisionTask.new(nil, nil, data) end
Fetches the workflow execution information used to fill in the
- DecisionTask][
-
details. Implementing classes must override this
method.
@return the workflow execution information as returned by
[AWS::SimpleWorkflow::Client#describe_workflow_execution][]. [AWS::SimpleWorkflow::Client#describe_workflow_execution]: http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/SimpleWorkflow/Client.html#describe_workflow_execution-instance_method
# File lib/aws/replayer.rb, line 113 def get_execution_info; end
Fetches the workflow history. Implementing classes must override this method.
@param page_token Optional. A token used to get further pages of
workflow history if all events could not be retrieved by the first call to the method.
@return a list of [HistoryEvent][]s that comprise the workflow’s
available history. [HistoryEvent]: http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/SimpleWorkflow/HistoryEvent.html
# File lib/aws/replayer.rb, line 103 def get_history(page_token = nil); end
Truncates workflow history to a specified event id.
@param events the workflow history (events) to truncate.
@param replay_upto [Fixnum] Optional. The event ID of the final
[HistoryEvent][] to return. [HistoryEvent]: http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/SimpleWorkflow/HistoryEvent.html
@return the truncated list of events.
# File lib/aws/replayer.rb, line 78 def truncate_history(events, replay_upto = nil) return nil if events.nil? || events.empty? # Just return the original array of events if replay_upto is not set # or if the number of events is less than replay_upto return events if replay_upto.nil? || events.last['eventId'] <= replay_upto # Select the events whose eventId is lesser than replay_upto truncated = events.select { |event| event['eventId'] <= replay_upto } return nil if truncated.empty? truncated end