Class WorkflowStateMachines

java.lang.Object
io.temporal.internal.statemachines.WorkflowStateMachines

public final class WorkflowStateMachines extends Object
  • Field Details

    • initialFlags

      public static List<SdkFlag> initialFlags
      Initial set of SDK flags that will be set on all new workflow executions.
  • Constructor Details

  • Method Details

    • setWorkflowStartedEventId

      public void setWorkflowStartedEventId(long workflowTaskStartedEventId)
      Parameters:
      workflowTaskStartedEventId - eventId of the workflowTask that was picked up by a worker and triggered an execution. Used in WorkflowTaskStateMachine only to understand that this workflow task will not have a matching closing event and needs to be executed.
    • resetStartedEventId

      public void resetStartedEventId(long eventId)
    • getLastWFTStartedEventId

      public long getLastWFTStartedEventId()
    • getCurrentWFTStartedEventId

      public long getCurrentWFTStartedEventId()
    • getHistorySize

      public long getHistorySize()
    • getCurrentTaskBuildId

      @Nullable public String getCurrentTaskBuildId()
    • isContinueAsNewSuggested

      public boolean isContinueAsNewSuggested()
    • getSuggestContinueAsNewReasons

      public List<SuggestContinueAsNewReason> getSuggestContinueAsNewReasons()
    • isTargetWorkerDeploymentVersionChanged

      public boolean isTargetWorkerDeploymentVersionChanged()
    • setReplaying

      public void setReplaying(boolean replaying)
    • setMessages

      public void setMessages(List<io.temporal.api.protocol.v1.Message> messages)
    • handleEvent

      public void handleEvent(io.temporal.api.history.v1.HistoryEvent event, boolean hasNextEvent)
      Handle a single event from the workflow history.
      Parameters:
      event - event from the history.
      hasNextEvent - false if this is the last event in the history.
    • takeCommands

      public List<io.temporal.api.command.v1.Command> takeCommands()
    • sendMessage

      public void sendMessage(io.temporal.api.protocol.v1.Message message)
    • takeMessages

      public List<io.temporal.api.protocol.v1.Message> takeMessages()
    • tryUseSdkFlag

      public boolean tryUseSdkFlag(SdkFlag flag)
      Returns:
      True if the SDK flag is supported in this workflow execution
    • checkSdkFlag

      public boolean checkSdkFlag(SdkFlag flag)
      Returns:
      True if the SDK flag is set in the workflow execution
    • takeNewSdkFlags

      public EnumSet<SdkFlag> takeNewSdkFlags()
      Returns:
      Set of all new flags set since the last call
    • sdkNameToWrite

      public String sdkNameToWrite()
      Returns:
      If we need to write the SDK name upon WFT completion, return it
    • sdkVersionToWrite

      public String sdkVersionToWrite()
      Returns:
      If we need to write the SDK version upon WFT completion, return it
    • getLastStartedEventId

      public long getLastStartedEventId()
    • getPostCompletionMetricCounter

      public String getPostCompletionMetricCounter()
    • getPostCompletionEndToEndLatency

      public com.uber.m3.util.Duration getPostCompletionEndToEndLatency()
    • setPostCompletionEndToEndLatency

      public void setPostCompletionEndToEndLatency(com.uber.m3.util.Duration postCompletionEndToEndLatency)
    • scheduleActivityTask

      public Functions.Proc scheduleActivityTask(ExecuteActivityParameters attributes, Functions.Proc2<Optional<io.temporal.api.common.v1.Payloads>,io.temporal.api.failure.v1.Failure> callback)
      Parameters:
      attributes - attributes used to schedule an activity
      callback - completion callback
      Returns:
      an instance of ActivityCommands
    • newTimer

      public Functions.Proc newTimer(io.temporal.api.command.v1.StartTimerCommandAttributes attributes, io.temporal.api.sdk.v1.UserMetadata metadata, Functions.Proc1<io.temporal.api.history.v1.HistoryEvent> completionCallback)
      Creates a new timer state machine
      Parameters:
      attributes - timer command attributes
      metadata - user provided metadata
      completionCallback - invoked when timer fires or reports cancellation. One of TimerFiredEvent, TimerCanceledEvent.
      Returns:
      cancellation callback that should be invoked to initiate timer cancellation
    • startChildWorkflow

      public Functions.Proc startChildWorkflow(StartChildWorkflowExecutionParameters parameters, Functions.Proc2<io.temporal.api.common.v1.WorkflowExecution,Exception> startedCallback, Functions.Proc2<Optional<io.temporal.api.common.v1.Payloads>,Exception> completionCallback)
      Creates a new child state machine
      Parameters:
      parameters - child workflow start command parameters
      startedCallback - callback that is notified about child start
      completionCallback - invoked when child reports completion or failure
      Returns:
      cancellation callback that should be invoked to cancel the child
    • startNexusOperation

      public Functions.Proc startNexusOperation(StartNexusOperationParameters parameters, Functions.Proc2<Optional<String>,io.temporal.api.failure.v1.Failure> startedCallback, Functions.Proc2<Optional<io.temporal.api.common.v1.Payload>,io.temporal.api.failure.v1.Failure> completionCallback)
    • signalExternalWorkflowExecution

      public Functions.Proc signalExternalWorkflowExecution(io.temporal.api.command.v1.SignalExternalWorkflowExecutionCommandAttributes attributes, Functions.Proc2<Void,io.temporal.api.failure.v1.Failure> completionCallback)
      Parameters:
      attributes -
      completionCallback - invoked when signal delivery completes of fails. The following types
    • requestCancelExternalWorkflowExecution

      public void requestCancelExternalWorkflowExecution(io.temporal.api.command.v1.RequestCancelExternalWorkflowExecutionCommandAttributes attributes, Functions.Proc2<Void,RuntimeException> completionCallback)
      Parameters:
      attributes - attributes to use to cancel external workflow
      completionCallback - one of ExternalWorkflowExecutionCancelRequestedEvent,
    • requestCancelNexusOperation

      public void requestCancelNexusOperation(io.temporal.api.command.v1.RequestCancelNexusOperationCommandAttributes attributes, Functions.Proc2<Void,io.temporal.api.failure.v1.Failure> completionCallback)
      Parameters:
      attributes - attributes to use to cancel a nexus operation
      completionCallback - one of NexusOperationCancelRequestCompleted or NexusOperationCancelRequestFailed events
    • upsertSearchAttributes

      public void upsertSearchAttributes(io.temporal.api.common.v1.SearchAttributes attributes)
    • upsertMemo

      public void upsertMemo(io.temporal.api.common.v1.Memo memo)
    • completeWorkflow

      public void completeWorkflow(Optional<io.temporal.api.common.v1.Payloads> workflowOutput)
    • failWorkflow

      public void failWorkflow(io.temporal.api.failure.v1.Failure failure)
    • cancelWorkflow

      public void cancelWorkflow()
    • continueAsNewWorkflow

      public void continueAsNewWorkflow(io.temporal.api.command.v1.ContinueAsNewWorkflowExecutionCommandAttributes attributes)
    • isReplaying

      public boolean isReplaying()
    • currentTimeMillis

      public long currentTimeMillis()
    • randomUUID

      public UUID randomUUID()
    • newRandom

      public Random newRandom()
    • sideEffect

      public void sideEffect(Functions.Func<Optional<io.temporal.api.common.v1.Payloads>> func, io.temporal.api.sdk.v1.UserMetadata userMetadata, Functions.Proc1<Optional<io.temporal.api.common.v1.Payloads>> callback)
    • mutableSideEffect

      public void mutableSideEffect(String id, io.temporal.api.sdk.v1.UserMetadata userMetadata, Functions.Func1<Optional<io.temporal.api.common.v1.Payloads>,Optional<io.temporal.api.common.v1.Payloads>> func, Functions.Proc1<Optional<io.temporal.api.common.v1.Payloads>> callback)
      Parameters:
      id - mutable side effect id
      func - given the value from the last marker returns value to store. If result is empty nothing is recorded into the history.
      callback - used to report result or failure
    • getVersion

      public Integer getVersion(String changeId, int minSupported, int maxSupported, Functions.Proc2<Integer,RuntimeException> callback)
    • takeLocalActivityRequests

      public List<ExecuteLocalActivityParameters> takeLocalActivityRequests()
    • handleLocalActivityCompletion

      public void handleLocalActivityCompletion(LocalActivityResult laCompletion)
    • scheduleLocalActivityTask

      public Functions.Proc scheduleLocalActivityTask(ExecuteLocalActivityParameters parameters, Functions.Proc2<Optional<io.temporal.api.common.v1.Payloads>,LocalActivityCallback.LocalActivityFailedException> callback)