Class WorkflowInternal


  • public final class WorkflowInternal
    extends java.lang.Object
    Never reference directly. It is public only because Java doesn't have internal package support.
    • Method Detail

      • newWorkflowMethodThread

        public static WorkflowThread newWorkflowMethodThread​(java.lang.Runnable runnable,
                                                             java.lang.String name)
      • newTimer

        public static Promise<java.lang.Void> newTimer​(java.time.Duration duration)
      • newQueue

        @Deprecated
        public static <E> WorkflowQueue<E> newQueue​(int capacity)
        Deprecated.
        this method created a deprecated implementation of the queue that has some methods implemented incorrectly. Please use newWorkflowQueue(int) instead.
        Parameters:
        capacity - the maximum size of the queue
        Returns:
        new instance of WorkflowQueue
      • newWorkflowQueue

        public static <E> WorkflowQueue<E> newWorkflowQueue​(int capacity)
        Creates a WorkflowQueue implementation that can be used from workflow code.
        Parameters:
        capacity - the maximum size of the queue
        Returns:
        new instance of WorkflowQueue
      • newCompletablePromise

        public static <E> CompletablePromise<E> newCompletablePromise()
      • newPromise

        public static <E> Promise<E> newPromise​(E value)
      • newFailedPromise

        public static <E> Promise<E> newFailedPromise​(java.lang.Exception failure)
      • registerListener

        public static void registerListener​(java.lang.Object implementation)
        Register query or queries implementation object. There is no need to register top level workflow implementation object as it is done implicitly. Only methods annotated with @QueryMethod are registered.
      • currentTimeMillis

        public static long currentTimeMillis()
        Should be used to get current time instead of System.currentTimeMillis()
      • setDefaultActivityOptions

        public static void setDefaultActivityOptions​(ActivityOptions activityOptions)
      • applyActivityOptions

        public static void applyActivityOptions​(java.util.Map<java.lang.String,​ActivityOptions> activityTypeToOptions)
      • setDefaultLocalActivityOptions

        public static void setDefaultLocalActivityOptions​(LocalActivityOptions localActivityOptions)
      • applyLocalActivityOptions

        public static void applyLocalActivityOptions​(java.util.Map<java.lang.String,​LocalActivityOptions> activityTypeToOptions)
      • newActivityStub

        public static <T> T newActivityStub​(java.lang.Class<T> activityInterface,
                                            ActivityOptions options,
                                            java.util.Map<java.lang.String,​ActivityOptions> activityMethodOptions)
        Creates client stub to activities that implement given interface.
        Parameters:
        activityInterface - interface type implemented by activities
        options - options that together with the properties of ActivityMethod specify the activity invocation parameters
        activityMethodOptions - activity method-specific invocation parameters
      • newLocalActivityStub

        public static <T> T newLocalActivityStub​(java.lang.Class<T> activityInterface,
                                                 LocalActivityOptions options,
                                                 @Nullable
                                                 java.util.Map<java.lang.String,​LocalActivityOptions> activityMethodOptions)
        Creates client stub to local activities that implement given interface.
        Parameters:
        activityInterface - interface type implemented by activities
        options - options that together with the properties of ActivityMethod specify the activity invocation parameters
        activityMethodOptions - activity method-specific invocation parameters
      • newChildWorkflowStub

        public static <T> T newChildWorkflowStub​(java.lang.Class<T> workflowInterface,
                                                 ChildWorkflowOptions options)
      • newExternalWorkflowStub

        public static <T> T newExternalWorkflowStub​(java.lang.Class<T> workflowInterface,
                                                    io.temporal.api.common.v1.WorkflowExecution execution)
      • getWorkflowExecution

        public static Promise<io.temporal.api.common.v1.WorkflowExecution> getWorkflowExecution​(java.lang.Object workflowStub)
      • newUntypedExternalWorkflowStub

        public static ExternalWorkflowStub newUntypedExternalWorkflowStub​(io.temporal.api.common.v1.WorkflowExecution execution)
      • newContinueAsNewStub

        public static <T> T newContinueAsNewStub​(java.lang.Class<T> workflowInterface,
                                                 ContinueAsNewOptions options)
        Creates client stub that can be used to continue this workflow as new.
        Parameters:
        workflowInterface - interface type implemented by the next generation of workflow
      • executeActivity

        public static <R> R executeActivity​(java.lang.String name,
                                            ActivityOptions options,
                                            java.lang.Class<R> resultClass,
                                            java.lang.reflect.Type resultType,
                                            java.lang.Object... args)
        Execute activity by name.
        Type Parameters:
        R - activity return type
        Parameters:
        name - name of the activity
        resultClass - activity return type
        args - list of activity arguments
        Returns:
        activity result
      • await

        public static void await​(java.lang.String reason,
                                 java.util.function.Supplier<java.lang.Boolean> unblockCondition)
                          throws io.temporal.internal.sync.DestroyWorkflowThreadError
        Throws:
        io.temporal.internal.sync.DestroyWorkflowThreadError
      • await

        public static boolean await​(java.time.Duration timeout,
                                    java.lang.String reason,
                                    java.util.function.Supplier<java.lang.Boolean> unblockCondition)
                             throws io.temporal.internal.sync.DestroyWorkflowThreadError
        Throws:
        io.temporal.internal.sync.DestroyWorkflowThreadError
      • sideEffect

        public static <R> R sideEffect​(java.lang.Class<R> resultClass,
                                       java.lang.reflect.Type resultType,
                                       Functions.Func<R> func)
      • mutableSideEffect

        public static <R> R mutableSideEffect​(java.lang.String id,
                                              java.lang.Class<R> resultClass,
                                              java.lang.reflect.Type resultType,
                                              java.util.function.BiPredicate<R,​R> updated,
                                              Functions.Func<R> func)
      • getVersion

        public static int getVersion​(java.lang.String changeId,
                                     int minSupported,
                                     int maxSupported)
      • promiseAllOf

        public static <V> Promise<java.lang.Void> promiseAllOf​(java.lang.Iterable<Promise<V>> promises)
      • promiseAllOf

        public static Promise<java.lang.Void> promiseAllOf​(Promise<?>... promises)
      • promiseAnyOf

        public static <V> Promise<V> promiseAnyOf​(java.lang.Iterable<Promise<V>> promises)
      • promiseAnyOf

        public static Promise<java.lang.Object> promiseAnyOf​(Promise<?>... promises)
      • newCancellationScope

        public static CancellationScope newCancellationScope​(boolean detached,
                                                             java.lang.Runnable runnable)
      • currentCancellationScope

        public static io.temporal.internal.sync.CancellationScopeImpl currentCancellationScope()
      • wrap

        public static java.lang.RuntimeException wrap​(java.lang.Throwable e)
      • unwrap

        public static java.lang.Throwable unwrap​(java.lang.Throwable e)
      • isReplaying

        public static boolean isReplaying()
        Returns false if not under workflow code.
      • getWorkflowInfo

        public static WorkflowInfo getWorkflowInfo()
      • getMemo

        public static <T> T getMemo​(java.lang.String key,
                                    java.lang.Class<T> valueClass,
                                    java.lang.reflect.Type valueType)
      • retry

        public static <R> R retry​(RetryOptions options,
                                  java.util.Optional<java.time.Duration> expiration,
                                  Functions.Func<R> fn)
      • continueAsNew

        public static void continueAsNew​(@Nullable
                                         java.lang.String workflowType,
                                         @Nullable
                                         ContinueAsNewOptions options,
                                         java.lang.Object[] args)
      • cancelWorkflow

        public static Promise<java.lang.Void> cancelWorkflow​(io.temporal.api.common.v1.WorkflowExecution execution)
      • sleep

        public static void sleep​(java.time.Duration duration)
      • getMetricsScope

        public static com.uber.m3.tally.Scope getMetricsScope()
      • randomUUID

        public static java.util.UUID randomUUID()
      • newRandom

        public static java.util.Random newRandom()
      • getLogger

        public static org.slf4j.Logger getLogger​(java.lang.Class<?> clazz)
      • getLogger

        public static org.slf4j.Logger getLogger​(java.lang.String name)
      • getLastCompletionResult

        public static <R> R getLastCompletionResult​(java.lang.Class<R> resultClass,
                                                    java.lang.reflect.Type resultType)
      • getSearchAttribute

        @Nullable
        public static <T> T getSearchAttribute​(java.lang.String name)
      • getSearchAttributeValues

        @Nullable
        public static <T> java.util.List<T> getSearchAttributeValues​(java.lang.String name)
      • getSearchAttributes

        @Nonnull
        public static java.util.Map<java.lang.String,​java.util.List<?>> getSearchAttributes()
      • upsertSearchAttributes

        public static void upsertSearchAttributes​(java.util.Map<java.lang.String,​?> searchAttributes)
      • getDataConverter

        public static DataConverter getDataConverter()
      • getWorkflowType

        public static java.lang.String getWorkflowType​(java.lang.Class<?> workflowInterfaceClass)
        Name of the workflow type the interface defines. It is either the interface short name * or value of WorkflowMethod.name() parameter.
        Parameters:
        workflowInterfaceClass - interface annotated with @WorkflowInterface
      • getPreviousRunFailure

        public static java.util.Optional<java.lang.Exception> getPreviousRunFailure()