Module: AWS::Flow::Workflows::InstanceMethods
- Defined in:
- lib/aws/decider/decider.rb
Overview
Instance methods for DecisionContext
Instance Method Summary collapse
-
#activity_client(name = nil, &block) ⇒ Object
Sets the activity client for this decision context.
-
#continue_as_new(*args, &block) ⇒ Object
Restarts the workflow as a new workflow execution.
-
#create_timer(delay_seconds, &block) ⇒ Object
Creates a timer on the workflow that executes the supplied block after a specified delay.
-
#create_timer_async(delay_seconds, &block) ⇒ Object
Creates an asynchronous timer on the workflow that executes the supplied block after a specified delay.
-
#decision_context ⇒ DecisionContext
Returns the DecisionContext instance.
- #decision_helper ⇒ Object
-
#run_id ⇒ Object
Returns the decision helper for the decision context.
-
#workflow_id ⇒ Object
Returns the workflow ID.
Instance Method Details
#activity_client(name = nil, &block) ⇒ Object
Sets the activity client for this decision context.
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
# File 'lib/aws/decider/decider.rb', line 414 def activity_client(name=nil, &block) = Utilities::(ActivityOptions, block) begin activity_class = get_const(.prefix_name) rescue Exception => e #pass end = {} if activity_class values = activity_class.activities.map{|x| [x.name.split(".").last.to_sym, x.]} = Hash[*values.flatten] end client = GenericActivityClient.new(self.decision_helper, ) self.class.send(:define_method, name) { client } if ! name.nil? client end |
#continue_as_new(*args, &block) ⇒ Object
Restarts the workflow as a new workflow execution.
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
# File 'lib/aws/decider/decider.rb', line 474 def continue_as_new(*args, &block) = Utilities::(ContinueAsNewOptions, block) @data_converter ||= YAMLDataConverter.new if ! args.empty? input = @data_converter.dump args .input = input end known_workflows = self.class.workflows # If there is only one workflow, we can unambiguously say that we should use that one if known_workflows.length == 1 .precursors << known_workflows.first. end # If we can find a name that matches, use that one if .execution_method matching_option = self.class.workflows.map(&:options).find {|x| x.execution_method == .execution_method } .precursors << matching_option unless matching_option.nil? end self.decision_context.workflow_context. = end |
#create_timer(delay_seconds, &block) ⇒ Object
Creates a timer on the workflow that executes the supplied block after a specified delay.
440 441 442 |
# File 'lib/aws/decider/decider.rb', line 440 def create_timer(delay_seconds, &block) self.decision_context.workflow_clock.create_timer(delay_seconds, block) end |
#create_timer_async(delay_seconds, &block) ⇒ Object
Creates an asynchronous timer on the workflow that executes the supplied block after a specified delay.
461 462 463 |
# File 'lib/aws/decider/decider.rb', line 461 def create_timer_async(delay_seconds, &block) AWS::Flow::Core::task { self.decision_context.workflow_clock.create_timer(delay_seconds, block) } end |
#decision_context ⇒ DecisionContext
Returns the DecisionContext instance.
381 382 383 |
# File 'lib/aws/decider/decider.rb', line 381 def decision_context FlowFiber.current[:decision_context] end |
#decision_helper ⇒ Object
401 402 403 |
# File 'lib/aws/decider/decider.rb', line 401 def decision_helper FlowFiber.current[:decision_context].decision_helper end |
#run_id ⇒ Object
Returns the decision helper for the decision context. This should be an instance of DecisionHelper or a class derived from it.
397 398 399 |
# File 'lib/aws/decider/decider.rb', line 397 def run_id self.decision_context.workflow_context.decision_task.workflow_execution.run_id end |
#workflow_id ⇒ Object
Returns the workflow ID.
391 392 393 |
# File 'lib/aws/decider/decider.rb', line 391 def workflow_id self.decision_context.workflow_context.decision_task.workflow_execution.workflow_id end |