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

.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.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/aws/decider/utilities.rb', line 63

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.



116
117
118
119
120
121
122
123
# File 'lib/aws/decider/utilities.rb', line 116

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