module AWS::Flow::Workflows
Types and methods related to workflow execution. Extend this to implement a workflow decider.
@!attribute version
Sets or returns the decider version.
@!attribute options
Sets or returns the {WorkflowOptions} for this decider.
Attributes
version[RW]
workflows[RW]
Public Class Methods
extended(base)
click to toggle source
# File lib/aws/decider/decider.rb, line 258 def self.extended(base) base.send :include, InstanceMethods end
Public Instance Methods
_options()
click to toggle source
@api private
# File lib/aws/decider/decider.rb, line 343 def _options; @workflows; end
activity_client(name, &block)
click to toggle source
Sets the activity client.
@param name
Sets the client name for the activity client.
@param block
A block of {ActivityOptions} for the activity client.
# File lib/aws/decider/decider.rb, line 299 def activity_client(name, &block) options = Utilities::interpret_block_for_options(ActivityOptions, block) # TODO: Make sure this works for dynamic stuff begin activity_class = get_const(options.prefix_name) rescue Exception => e #pass end activity_options = {} if activity_class values = activity_class.activities.map{|x| [x.name.split(".").last.to_sym, x.options]} activity_options = Hash[*values.flatten] end # define_method(name) do # return @client if @client # @client ||= activity_class.activity_client.new(@decision_helper, options) # @client.decision_context = @decision_context # @client # end # else client_name = "@client_#{name}" define_method(name) do return instance_variable_get(client_name) if instance_variable_get(client_name) @decision_context ||= Fiber.current[:decision_context] @decision_helper ||= @decision_context.decision_helper @decision_helper.activity_options = activity_options instance_variable_set(client_name, GenericActivityClient.new(@decision_helper, options)) instance_variable_get(client_name) end instance_variable_get(client_name) end
child_workflow_client(name, &block)
click to toggle source
Convenience method to set the child workflow client
# File lib/aws/decider/decider.rb, line 333 def child_workflow_client(name, &block) client_name = "@child_client_#{name}" define_method(name) do return instance_variable_get(client_name) if instance_variable_get(client_name) client = AWS::Flow.send(:workflow_client, nil, nil, &block) end instance_variable_get(client_name) end
entry_point(input=nil)
click to toggle source
@deprecated Set the entry point with {Workflows#workflow} instead.
@api private
# File lib/aws/decider/decider.rb, line 265 def entry_point(input=nil) if input @entry_point = input workflow_type = WorkflowType.new(self.to_s + "." + input.to_s, nil, WorkflowRegistrationOptions.new(:execution_method => input)) @workflows ||= [] @workflows.each { |workflow| workflow.name = self.to_s + "." + input.to_s } @workflows.each do |workflow| workflow.options = WorkflowRegistrationOptions.new(:execution_method => input) end @workflows << workflow_type end return @entry_point if @entry_point raise "You must set an entry point on the workflow definition" end
get_state_method(get_state_method = nil, options = {})
click to toggle source
@return [MethodPair]
A {MethodPair} object.
# File lib/aws/decider/decider.rb, line 367 def get_state_method(get_state_method = nil, options = {}) data_converter = options[:data_converter] @get_state_method = MethodPair.new(get_state_method, data_converter) unless get_state_method.nil? @get_state_method end
look_upwards(variable)
click to toggle source
# File lib/aws/decider/decider.rb, line 249 def look_upwards(variable) unless self.ancestors.nil? precursors = self.ancestors.dup precursors.delete(self) results = precursors.map { |x| x.send(variable) if x.methods.map(&:to_sym).include? variable }.compact.flatten.uniq end end
signal(method_name , options = {})
click to toggle source
Defines a signal for the workflow.
@param method_name
The signal method for the workflow.
@param [SignalWorkflowOptions] options
The {SignalWorkflowOptions} for this signal.
# File lib/aws/decider/decider.rb, line 381 def signal(method_name , options = {}) data_converter = options[:data_converter] signal_name = options[:signal_name] signal_name ||= method_name.to_s data_converter ||= FlowConstants.data_converter @signals ||= {} @signals[signal_name] = MethodPair.new(method_name, data_converter) @signals end
signals()
click to toggle source
@return [Hash]
A hash of string(SignalName) => MethodPair(method, signalConverter) objects
# File lib/aws/decider/decider.rb, line 394 def signals @signals end
workflow(*workflow_names, &block)
click to toggle source
Defines a new workflow.
@param workflow_names
The entry points (methods) that starts the workflow.
@param block
A block of {WorkflowRegistrationOptions} for the workflow.
# File lib/aws/decider/decider.rb, line 353 def workflow(*workflow_names, &block) workflow_names.each do |workflow_name| options = Utilities::interpret_block_for_options(WorkflowRegistrationOptions, block) options.execution_method = workflow_name prefix_name = options.prefix_name || self.to_s workflow_type = WorkflowType.new(prefix_name.to_s + "." + workflow_name.to_s, options.version, options) @workflows ||= [] @workflows << workflow_type end end