class AWS::Flow::ActivityDefinition
Defines an executable activity.
@!attribute [ActivityOptions] execution_options
The {ActivityOptions} for this activity.
Attributes
execution_options[RW]
Public Class Methods
new(instance, activity_method, registration_options, execution_options, converter)
click to toggle source
Creates a new ActivityDefinition
instance.
@param [Object] instance
@param [Symbol] activity_method
The method to run when {#execute} is called.
@param [Hash] registration_options
@param [Hash] execution_options
The {ActivityOptions} for this activity.
@param [Object] converter
# 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
Public Instance Methods
execute(input, context)
click to toggle source
Executes the activity.
@param [Object] input
Additional input for the activity execution.
@param [ActivityExecutionContext] context
The context for the activity execution.
# 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 raise e if e.is_a? CancellationException # Check if serialized exception violates the 32k limit and truncate it reason, converted_failure = AWS::Flow::Utilities::check_and_truncate_exception(e, @converter) # Wrap the exception that we got into an ActivityFailureException so # that the task poller can handle it properly. raise ActivityFailureException.new(reason, converted_failure) 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 > FlowConstants::DATA_LIMIT return converted_result, result, true end return converted_result, result, false end