Class: AWS::Flow::ActivityDefinition
- Inherits:
-
Object
- Object
- AWS::Flow::ActivityDefinition
- Defined in:
- lib/aws/decider/activity_definition.rb
Overview
Defines an executable activity.
Instance Attribute Summary collapse
-
#execution_options ⇒ Object
Returns the value of attribute execution_options.
Instance Method Summary collapse
-
#execute(input, context) ⇒ Object
Executes the activity.
-
#initialize(instance, activity_method, registration_options, execution_options, converter) ⇒ ActivityDefinition
constructor
Creates a new ActivityDefinition instance.
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, , , converter) @instance = instance @activity_method = activity_method @registration_options = @execution_options = @converter = converter end |
Instance Attribute Details
#execution_options ⇒ Object
Returns the value of attribute execution_options.
25 26 27 |
# File 'lib/aws/decider/activity_definition.rb', line 25 def @execution_options end |
Instance Method Details
#execute(input, context) ⇒ Object
Executes the activity.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/aws/decider/activity_definition.rb', line 57 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., @converter.dump(e)) ensure @instance._activity_execution_context = nil end converted_result = @converter.dump(result) # We are going to have to convert this object into a string to submit it, and that's where the 32k limit will be enforced, so it's valid to turn the object to a string and check the size of the result if converted_result.to_s.size > 32768 return @converter.dump("The result was too large, so we could not serialize it correctly. You can find the full result in the ActivityTaskPoller logs."), result, true end return converted_result, result, false end |