Package io.temporal.workflow.unsafe
Class WorkflowUnsafe
- java.lang.Object
-
- io.temporal.workflow.unsafe.WorkflowUnsafe
-
public final class WorkflowUnsafe extends java.lang.Object
WhileWorkflow
contains methods exposing the main Temporal Workflow API that is safe to use by majority of our users, this class contains the part of the Workflow API that is discouraged to be used without careful consideration. While APIs in this class may be required for some legitimate scenarios, most users shouldn't be using them. Relying on these methods without careful consideration and understanding of limitations of each method may lead to an unexpected behavior and mistakes.Please reference a documentation for each specific method for more context why this method is considered unsafe to be a part of the main Workflow API.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
deadlockDetectorOff(Functions.Func<T> func)
Runs the supplied function in the calling thread with disabled deadlock detection if called from the workflow thread.static void
deadlockDetectorOff(Functions.Proc proc)
Runs the supplied procedure in the calling thread with disabled deadlock detection if called from the workflow thread.static boolean
isReplaying()
Warning!
Never make workflow code depend on this flag as it is going to break determinism.static boolean
isWorkflowThread()
Warning!
The only reasonable usage for this method is writing a library code that has to be used in both workflow and non-workflow code (like an Activity or non-Temporal codebase).
-
-
-
Method Detail
-
isWorkflowThread
public static boolean isWorkflowThread()
Warning!
The only reasonable usage for this method is writing a library code that has to be used in both workflow and non-workflow code (like an Activity or non-Temporal codebase). This usage is generally discouraged, because mixing of workflow and non-workflow code is error-prone, because workflow code requires considerations for determinism. Writing shared code that is designed to be called from both workflow and non-workflow context may lead to leaking of the code not written with Workflow limitations in mind into Workflow method implementation leading to non-deterministic Workflow implementations.- Returns:
- true if the current execution happens as a part of workflow method and in a workflow thread context.
-
isReplaying
public static boolean isReplaying()
Warning!
Never make workflow code depend on this flag as it is going to break determinism. The only reasonable uses for this flag is deduping external never failing side effects like logging or metric reporting.- Returns:
- true if workflow code is being replayed. This method always returns false if called from a non workflow thread.
-
deadlockDetectorOff
public static void deadlockDetectorOff(Functions.Proc proc)
Runs the supplied procedure in the calling thread with disabled deadlock detection if called from the workflow thread. Does nothing except the procedure execution if called from a non-workflow thread.Warning!
Never make workflow logic depend on this flag. Workflow code that runs into deadlock detector is implemented incorrectly. The intended use of this execution mode is blocking calls and IO inPayloadCodec
,PayloadConverter
orWorkerInterceptor
implementations.- Parameters:
proc
- to run with disabled deadlock detection
-
deadlockDetectorOff
public static <T> T deadlockDetectorOff(Functions.Func<T> func)
Runs the supplied function in the calling thread with disabled deadlock detection if called from the workflow thread. Does nothing except the function execution if called from a non-workflow thread.Warning!
Never make workflow code depend on this flag. Workflow code that runs into deadlock detector is implemented incorrectly (see ). The intended use of this execution mode is blocking calls and IO inPayloadCodec
,PayloadConverter
orWorkerInterceptor
implementations.- Type Parameters:
T
- type offunc
result- Parameters:
func
- to run with disabled deadlock detection- Returns:
- result of
func
execution
-
-