Class: AWS::Flow::Core::ExternalTaskCompletionHandle Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/flow/tasks.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(external_task) ⇒ ExternalTaskCompletionHandle

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.

Returns a new instance of ExternalTaskCompletionHandle.



320
321
322
# File 'lib/aws/flow/tasks.rb', line 320

def initialize(external_task)
  @external_task = external_task
end

Instance Attribute Details

#completedObject

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.



317
318
319
# File 'lib/aws/flow/tasks.rb', line 317

def completed
  @completed
end

#external_taskObject

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.



317
318
319
# File 'lib/aws/flow/tasks.rb', line 317

def external_task
  @external_task
end

#failureObject

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.



317
318
319
# File 'lib/aws/flow/tasks.rb', line 317

def failure
  @failure
end

Instance Method Details

#completeObject

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.

Sets the task to complete, and removes it from its parent.

Raises:

  • IllegalStateException If the failure hasn’t been set, or if the task is already completed.



360
361
362
363
364
365
366
367
368
369
370
# 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) ⇒ 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.

Merges the backtrace, sets the @failure, and then fails the task from the parent.

Parameters:

  • error

    The exception to fail on.

Raises:

  • IllegalStateException Raises if failure hasn’t been set, or if the task is already completed.



334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# 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