Class: AWS::Flow::DecisionTaskHandler
- Inherits:
-
Object
- Object
- AWS::Flow::DecisionTaskHandler
- Defined in:
- lib/aws/decider/task_handler.rb
Overview
A decision task handler to work with a WorkflowTaskPoller. Create a ‘DecisionTaskHandler` and pass it to WorkflowTaskPoller on construction.
Instance Attribute Summary collapse
-
#workflow_definition_map ⇒ Object
readonly
Returns the value of attribute workflow_definition_map.
Class Method Summary collapse
-
.from_workflow_class(workflow_class) ⇒ Object
Factory method to create a DecisionTaskHandler instance given a workflow class.
Instance Method Summary collapse
-
#create_async_decider(history_helper) ⇒ AsyncDecider
Creates a new asynchronous decider.
-
#handle_decision_task(decision_task_iterator) ⇒ Object
Handles a decision task.
-
#initialize(workflow_definition_map, options = nil) ⇒ DecisionTaskHandler
constructor
Creates a new ‘DecisionTaskHandler`.
Constructor Details
#initialize(workflow_definition_map, options = nil) ⇒ DecisionTaskHandler
Creates a new ‘DecisionTaskHandler`.
42 43 44 45 46 |
# File 'lib/aws/decider/task_handler.rb', line 42 def initialize(workflow_definition_map, =nil) @workflow_definition_map = workflow_definition_map @logger = .logger if @logger ||= Utilities::LogFactory.make_logger(self) end |
Instance Attribute Details
#workflow_definition_map ⇒ Object (readonly)
Returns the value of attribute workflow_definition_map.
33 34 35 |
# File 'lib/aws/decider/task_handler.rb', line 33 def workflow_definition_map @workflow_definition_map end |
Class Method Details
.from_workflow_class(workflow_class) ⇒ Object
Factory method to create a DecisionTaskHandler instance given a workflow class
28 29 30 |
# File 'lib/aws/decider/task_handler.rb', line 28 def from_workflow_class workflow_class self.new(WorkflowDefinitionFactory.generate_definition_map(workflow_class)) end |
Instance Method Details
#create_async_decider(history_helper) ⇒ AsyncDecider
Creates a new asynchronous decider.
71 72 73 74 75 76 77 78 |
# File 'lib/aws/decider/task_handler.rb', line 71 def create_async_decider(history_helper) task = history_helper.get_decision_task workflow_type = task.workflow_type # TODO put in context correctly workflow_definition_factory = @workflow_definition_map[workflow_type] raise "No such definition for #{workflow_type}" if workflow_definition_factory.nil? AsyncDecider.new(workflow_definition_factory, history_helper, DecisionHelper.new) end |
#handle_decision_task(decision_task_iterator) ⇒ Object
Handles a decision task.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/aws/decider/task_handler.rb', line 53 def handle_decision_task(decision_task_iterator) history_helper = HistoryHelper.new(decision_task_iterator) decider = create_async_decider(history_helper) decider.decide decisions = decider.get_decisions response = {:task_token => decider.task_token} context_data = decider.decision_helper.workflow_context_data response[:execution_context] = context_data.to_s unless context_data.nil? response[:decisions] = decisions unless decisions.nil? return response end |