Class: AWS::Flow::ActivityDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/decider/activity_definition.rb

Overview

Defines an executable activity.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance, activity_method, registration_options, execution_options, converter) ⇒ ActivityDefinition

Creates a new ActivityDefinition instance



41
42
43
44
45
46
47
# File 'lib/aws/decider/activity_definition.rb', line 41

def initialize(instance, activity_method, registration_options, execution_options, converter)
  @instance = instance
  @activity_method = activity_method
  @registration_options = registration_options
  @execution_options = execution_options
  @converter = converter
end

Instance Attribute Details

#execution_optionsObject

Returns the value of attribute execution_options.



25
26
27
# File 'lib/aws/decider/activity_definition.rb', line 25

def execution_options
  @execution_options
end

Instance Method Details

#execute(input, context) ⇒ Object

Executes the activity

Parameters



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/aws/decider/activity_definition.rb', line 59

def execute(input, context)
  begin
    @instance._activity_execution_context = context
    # Since we encode all the inputs in some converter, and these inputs
    # are not "true" ruby objects yet, there is no way for that input to
    # be an instance of the NilClass(the only thing that responds true to
    # .nil?) and thus we can be assured that if input.nil?, then the
    # method had no input
    if input.nil?
      result = @instance.send(@activity_method)
    else
      ruby_input = @converter.load input
      result = @instance.send(@activity_method, *ruby_input)
    end
  rescue Exception => e
    #TODO we need the proper error handling here
    raise e if e.is_a? CancellationException
    raise ActivityFailureException.new(e.message, @converter.dump(e))
  ensure
    @instance._activity_execution_context = nil
  end
  return @converter.dump result
end