Module: AWS::Flow::Utilities

Defined in:
lib/aws/decider/utilities.rb

Overview

Utilities for the AWS Flow Framework for Ruby.

Defined Under Namespace

Modules: SelfMethods, UpwardLookups Classes: AddressableFuture, LogFactory

Class Method Summary collapse

Class Method Details

.activity_task_to_debug_string(message, task) ⇒ Object



39
40
41
# File 'lib/aws/decider/utilities.rb', line 39

def self.activity_task_to_debug_string(message, task)
  return "#{message} #{task.activity_type.name}.#{task.activity_type.version} with input: #{task.input} and task_token: #{task.task_token}"
end

.client_options_from_method_name(method_name, options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/aws/decider/utilities.rb', line 62

def self.client_options_from_method_name(method_name, options)
  client_options = options.dup
  if method_name.nil?
    client_options.precursors = options.precursors.empty? ? [] : [options.precursors.first]
  else
    client_options.precursors = options.precursors.select { |x| x.name.split(".").last.to_sym == method_name }
  end

  unless options.precursors.empty?
    client_options.precursors.map!(&:options)
  end
  client_options
end

.drill_on_future(future) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



45
46
47
48
49
50
# File 'lib/aws/decider/utilities.rb', line 45

def self.drill_on_future(future)
  while (future.respond_to? :is_flow_future?) && future.is_flow_future?
    future = future.get
  end
  future
end

.interpret_block_for_options(option_class, block, use_defaults = false) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/aws/decider/utilities.rb', line 78

def self.interpret_block_for_options(option_class, block, use_defaults = false)

  return option_class.new({}, use_defaults) if block.nil?
  if block.arity <= 0
    result = block.call
    if result.is_a? Hash
      options = option_class.new(result, use_defaults)
    else
      raise "If using 0 arguments to the option configuration, you must return a hash"
    end
  else
    options = option_class.new({}, use_defaults)
    block.call(options)
  end

  if options.from_class
    # Insert into the next-to-last position, as these options should be used excepting where they might conflict with the options specified in the block
    klass = get_const(options.from_class) rescue nil
    if options.precursors.empty?
      options.precursors = klass._options
    else
      options.precursors.insert(-2, klass._options).flatten!
    end
    options.prefix_name ||= options.from_class
  end
  options
end

.is_externalObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



131
132
133
134
135
136
137
138
# File 'lib/aws/decider/utilities.rb', line 131

def self.is_external
  if (defined? Fiber).nil?
    return true
  elsif FlowFiber.current != nil && FlowFiber.current.class != Fiber && FlowFiber.current[:decision_context] != nil
    return false
  end
  return true
end

.merge_all_options(*args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



53
54
55
56
57
58
59
# File 'lib/aws/decider/utilities.rb', line 53

def self.merge_all_options(*args)
  args.compact!
  youngest = args.last
  args.delete(youngest)
  youngest.precursors.concat(args.reverse)
  youngest.get_full_options
end

.workflow_task_to_debug_string(message, task) ⇒ Object



36
37
38
# File 'lib/aws/decider/utilities.rb', line 36

def self.workflow_task_to_debug_string(message, task)
  return "#{message} #{task.workflow_type.name}.#{task.workflow_type.version} for execution with workflow_id: #{task.workflow_execution.workflow_id}, run_id: #{task.workflow_execution.run_id}, task_list: #{task.workflow_execution.task_list} with task_token: #{task.task_token}"
end