Interface CancellationScope

All Superinterfaces:
Runnable
All Known Subinterfaces:
WorkflowThread
All Known Implementing Classes:
RootWorkflowThreadImpl

public interface CancellationScope extends Runnable
Handle to a cancellation scope created through Workflow.newCancellationScope(Runnable) or Workflow.newDetachedCancellationScope(Runnable). Supports explicit cancelling of the code a cancellation scope wraps. The code in the CancellationScope has to be executed using Runnable.run() method.
  • Method Details

    • isDetached

      boolean isDetached()
      When set to false parent thread cancellation causes this one to get canceled automatically. When set to true only call to cancel() leads to this scope cancellation.
    • cancel

      void cancel()
      Cancels the scope as well as all its children
    • cancel

      void cancel(String reason)
      Cancels the scope as well as all its children.
      Parameters:
      reason - human-readable reason for the cancellation. Becomes message of the CanceledException thrown.
    • getCancellationReason

      String getCancellationReason()
    • isCancelRequested

      boolean isCancelRequested()
      Is scope was asked to cancel through cancel() or by a parent scope.
      Returns:
      whether request is canceled or not.
    • getCancellationRequest

      Promise<String> getCancellationRequest()
      Use this promise to perform cancellation of async operations.
      Returns:
      promise that becomes ready when scope is canceled. It contains reason value or null if none was provided.
    • current

      static CancellationScope current()
    • throwCanceled

      static void throwCanceled() throws CanceledFailure
      Throws CanceledFailure if scope is canceled. Noop if not canceled.
      Throws:
      CanceledFailure