class AWS::Flow::Core::ExternalTaskCompletionHandle
Used to complete or fail an external task initiated through ExternalTask#initiate_task
, and thus handles the logic of what to do when the external task is failed.
@api private
Attributes
completed[RW]
external_task[RW]
failure[RW]
Public Class Methods
new(external_task)
click to toggle source
@api private
# File lib/aws/flow/tasks.rb, line 320 def initialize(external_task) @external_task = external_task end
Public Instance Methods
complete()
click to toggle source
Sets the task to complete, and removes it from its parent.
@raise IllegalStateException
If the failure hasn't been set, or if the task is already completed.
@api private
# File lib/aws/flow/tasks.rb, line 360 def complete if ! failure.nil? raise IllegalStateException, "" end if @completed raise IllegalStateException, "Already Completed" end @completed = true @external_task.remove_from_parent if ! @external_task.inCancellationHandler end
fail(error)
click to toggle source
Merges the backtrace, sets the @failure, and then fails the task from the parent.
@param error
The exception to fail on.
@raise IllegalStateException
Raises if failure hasn't been set, or if the task is already completed.
@api private
# File lib/aws/flow/tasks.rb, line 334 def fail(error) if ! @failure.nil? raise IllegalStateException, "Invalid ExternalTaskCompletionHandle" end if @completed raise IllegalStateException, "Already completed" end #TODO Might want to flip the logic to only alert if variable is set if @stacktrace.nil? if ! @external_task.backtrace.nil? backtrace = AsyncBacktrace.create_from_exception(@external_task.backtrace, error) error.set_backtrace(backtrace.backtrace) if backtrace end end @failure = error if ! @external_task.inCancellationHandler @external_task.fail_to_parent(error) end end