Class Async

java.lang.Object
io.temporal.workflow.Async

public final class Async extends Object
Supports invoking lambdas and activity and child workflow references asynchronously.
  • Method Details

    • function

      public static <R> Promise<R> function(Functions.Func<R> function)
      Invokes zero argument function asynchronously.
      Parameters:
      function - Function to execute asynchronously
      Returns:
      promise that contains function result or failure
    • function

      public static <A1, R> Promise<R> function(Functions.Func1<A1,R> function, A1 arg1)
      Invokes one argument function asynchronously.
      Parameters:
      function - Function to execute asynchronously
      arg1 - first function argument
      Returns:
      promise that contains function result or failure
    • function

      public static <A1, A2, R> Promise<R> function(Functions.Func2<A1,A2,R> function, A1 arg1, A2 arg2)
      Invokes two argument function asynchronously.
      Parameters:
      function - Function to execute asynchronously
      arg1 - first function argument
      arg2 - second function argument
      Returns:
      Promise that contains function result or failure
    • function

      public static <A1, A2, A3, R> Promise<R> function(Functions.Func3<A1,A2,A3,R> function, A1 arg1, A2 arg2, A3 arg3)
      Invokes three argument function asynchronously.
      Parameters:
      function - Function to execute asynchronously
      arg1 - first function argument
      arg2 - second function argument
      arg3 - third function argument
      Returns:
      Promise that contains function result or failure
    • function

      public static <A1, A2, A3, A4, R> Promise<R> function(Functions.Func4<A1,A2,A3,A4,R> function, A1 arg1, A2 arg2, A3 arg3, A4 arg4)
      Invokes four argument function asynchronously.
      Parameters:
      function - Function to execute asynchronously
      arg1 - first function argument
      arg2 - second function argument
      arg3 - third function argument
      arg4 - forth function argument
      Returns:
      Promise that contains function result or failure
    • function

      public static <A1, A2, A3, A4, A5, R> Promise<R> function(Functions.Func5<A1,A2,A3,A4,A5,R> function, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5)
      Invokes five argument function asynchronously.
      Parameters:
      function - Function to execute asynchronously
      arg1 - first function argument
      arg2 - second function argument
      arg3 - third function argument
      arg4 - forth function argument
      arg5 - fifth function argument
      Returns:
      Promise that contains function result or failure
    • function

      public static <A1, A2, A3, A4, A5, A6, R> Promise<R> function(Functions.Func6<A1,A2,A3,A4,A5,A6,R> function, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6)
      Invokes six argument function asynchronously.
      Parameters:
      function - Function to execute asynchronously
      arg1 - first function argument
      arg2 - second function argument
      arg3 - third function argument
      arg4 - forth function argument
      arg5 - fifth function argument
      arg6 - sixth function argument
      Returns:
      Promise that contains function result or failure
    • procedure

      public static Promise<Void> procedure(Functions.Proc procedure)
      Invokes zero argument procedure asynchronously.
      Parameters:
      procedure - Procedure to execute asynchronously
      Returns:
      Promise that contains procedure result or failure
    • procedure

      public static <A1> Promise<Void> procedure(Functions.Proc1<A1> procedure, A1 arg1)
      Invokes one argument procedure asynchronously.
      Parameters:
      procedure - Procedure to execute asynchronously
      arg1 - first procedure argument
      Returns:
      Promise that contains procedure result or failure
    • procedure

      public static <A1, A2> Promise<Void> procedure(Functions.Proc2<A1,A2> procedure, A1 arg1, A2 arg2)
      Invokes two argument procedure asynchronously.
      Parameters:
      procedure - Procedure to execute asynchronously
      arg1 - first procedure argument
      arg2 - second procedure argument
      Returns:
      Promise that contains procedure result or failure
    • procedure

      public static <A1, A2, A3> Promise<Void> procedure(Functions.Proc3<A1,A2,A3> procedure, A1 arg1, A2 arg2, A3 arg3)
      Invokes three argument procedure asynchronously.
      Parameters:
      procedure - Procedure to execute asynchronously
      arg1 - first procedure argument
      arg2 - second procedure argument
      arg3 - third procedure argument
      Returns:
      Promise that contains procedure result or failure
    • procedure

      public static <A1, A2, A3, A4> Promise<Void> procedure(Functions.Proc4<A1,A2,A3,A4> procedure, A1 arg1, A2 arg2, A3 arg3, A4 arg4)
      Invokes four argument procedure asynchronously.
      Parameters:
      procedure - Procedure to execute asynchronously
      arg1 - first procedure argument
      arg2 - second procedure argument
      arg3 - third procedure argument
      arg4 - forth procedure argument
      Returns:
      Promise that contains procedure result or failure
    • procedure

      public static <A1, A2, A3, A4, A5> Promise<Void> procedure(Functions.Proc5<A1,A2,A3,A4,A5> procedure, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5)
      Invokes five argument procedure asynchronously.
      Parameters:
      procedure - Procedure to execute asynchronously
      arg1 - first procedure argument
      arg2 - second procedure argument
      arg3 - third procedure argument
      arg4 - forth procedure argument
      arg5 - fifth procedure argument
      Returns:
      Promise that contains procedure result or failure
    • procedure

      public static <A1, A2, A3, A4, A5, A6> Promise<Void> procedure(Functions.Proc6<A1,A2,A3,A4,A5,A6> procedure, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6)
      Invokes six argument procedure asynchronously.
      Parameters:
      procedure - Procedure to execute asynchronously
      arg1 - first procedure argument
      arg2 - second procedure argument
      arg3 - third procedure argument
      arg4 - forth procedure argument
      arg5 - fifth procedure argument
      arg6 - sixth procedure argument
      Returns:
      Promise that contains procedure result or failure
    • await

      public static Promise<Void> await(Supplier<Boolean> unblockCondition)
      Returns a promise that completes with null when unblockCondition evaluates to true. Unlike Workflow.await(Supplier), this method does not block the calling workflow thread.

      The condition is evaluated on every workflow state transition. It must not call blocking operations or mutate workflow state. It must also not contain time-based conditions; use await(Duration, Supplier) for those.

      If the CancellationScope active when this method is invoked is canceled, the promise completes exceptionally with a CanceledFailure. An exception thrown by the condition also completes the promise exceptionally.

      Parameters:
      unblockCondition - condition that completes the promise when satisfied.
      Returns:
      promise that completes when the condition is satisfied.
    • await

      public static Promise<Boolean> await(Duration timeout, Supplier<Boolean> unblockCondition)
      Returns a promise that completes with true when unblockCondition evaluates to true, or with false when timeout expires. Unlike Workflow.await(Duration, Supplier), this method does not block the calling workflow thread.

      The condition is evaluated on every workflow state transition. It must not call blocking operations or mutate workflow state. It must also not contain time-based conditions; use the timeout parameter for those.

      If the CancellationScope active when this method is invoked is canceled, the promise completes exceptionally with a CanceledFailure. An exception thrown by the condition also completes the promise exceptionally.

      Parameters:
      timeout - time after which the promise completes with false if the condition is not satisfied.
      unblockCondition - condition that completes the promise with true when satisfied.
      Returns:
      promise that contains whether the condition was satisfied before the timeout.
    • retry

      public static <R> Promise<R> retry(RetryOptions options, Optional<Duration> expiration, Functions.Func<Promise<R>> fn)
      Invokes function retrying in case of failures according to retry options. Asynchronous variant. Use Workflow.retry(RetryOptions, Optional, Functions.Func) for synchronous functions.
      Parameters:
      options - retry options that specify retry policy
      expiration - if provided limits duration of retries
      fn - function to invoke and retry
      Returns:
      result of the function or the last failure.