Class WorkflowStateMachines
java.lang.Object
io.temporal.internal.statemachines.WorkflowStateMachines
-
Field Summary
FieldsModifier and TypeFieldDescriptionInitial set of SDK flags that will be set on all new workflow executions. -
Constructor Summary
ConstructorsConstructorDescriptionWorkflowStateMachines(StatesMachinesCallback callbacks, io.temporal.api.workflowservice.v1.GetSystemInfoResponse.Capabilities capabilities, WorkflowImplementationOptions workflowImplOptions) WorkflowStateMachines(StatesMachinesCallback callbacks, Functions.Proc1<io.temporal.internal.statemachines.StateMachine> stateMachineSink) WorkflowStateMachines(StatesMachinesCallback callbacks, Functions.Proc1<io.temporal.internal.statemachines.StateMachine> stateMachineSink, io.temporal.api.workflowservice.v1.GetSystemInfoResponse.Capabilities capabilities, WorkflowImplementationOptions workflowImplOptions) -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleancheckSdkFlag(SdkFlag flag) voidcompleteWorkflow(Optional<io.temporal.api.common.v1.Payloads> workflowOutput) voidcontinueAsNewWorkflow(io.temporal.api.command.v1.ContinueAsNewWorkflowExecutionCommandAttributes attributes) longvoidfailWorkflow(io.temporal.api.failure.v1.Failure failure) longlonglonglongcom.uber.m3.util.DurationgetVersion(String changeId, int minSupported, int maxSupported, Functions.Proc2<Integer, RuntimeException> callback) voidhandleEvent(io.temporal.api.history.v1.HistoryEvent event, boolean hasNextEvent) Handle a single event from the workflow history.voidhandleLocalActivityCompletion(LocalActivityResult laCompletion) booleanbooleanbooleanvoidmutableSideEffect(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) 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 machinevoidrequestCancelExternalWorkflowExecution(io.temporal.api.command.v1.RequestCancelExternalWorkflowExecutionCommandAttributes attributes, Functions.Proc2<Void, RuntimeException> completionCallback) voidrequestCancelNexusOperation(io.temporal.api.command.v1.RequestCancelNexusOperationCommandAttributes attributes, Functions.Proc2<Void, io.temporal.api.failure.v1.Failure> completionCallback) voidresetStartedEventId(long eventId) scheduleActivityTask(ExecuteActivityParameters attributes, Functions.Proc2<Optional<io.temporal.api.common.v1.Payloads>, io.temporal.api.failure.v1.Failure> callback) scheduleLocalActivityTask(ExecuteLocalActivityParameters parameters, Functions.Proc2<Optional<io.temporal.api.common.v1.Payloads>, LocalActivityCallback.LocalActivityFailedException> callback) voidsendMessage(io.temporal.api.protocol.v1.Message message) voidsetMessages(List<io.temporal.api.protocol.v1.Message> messages) voidsetPostCompletionEndToEndLatency(com.uber.m3.util.Duration postCompletionEndToEndLatency) voidsetReplaying(boolean replaying) voidsetWorkflowStartedEventId(long workflowTaskStartedEventId) voidsideEffect(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) signalExternalWorkflowExecution(io.temporal.api.command.v1.SignalExternalWorkflowExecutionCommandAttributes attributes, Functions.Proc2<Void, io.temporal.api.failure.v1.Failure> completionCallback) 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 machinestartNexusOperation(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) List<io.temporal.api.command.v1.Command> List<io.temporal.api.protocol.v1.Message> booleantryUseSdkFlag(SdkFlag flag) voidupsertMemo(io.temporal.api.common.v1.Memo memo) voidupsertSearchAttributes(io.temporal.api.common.v1.SearchAttributes attributes)
-
Field Details
-
initialFlags
-
-
Constructor Details
-
WorkflowStateMachines
public WorkflowStateMachines(StatesMachinesCallback callbacks, io.temporal.api.workflowservice.v1.GetSystemInfoResponse.Capabilities capabilities, WorkflowImplementationOptions workflowImplOptions) -
WorkflowStateMachines
public WorkflowStateMachines(StatesMachinesCallback callbacks, Functions.Proc1<io.temporal.internal.statemachines.StateMachine> stateMachineSink, io.temporal.api.workflowservice.v1.GetSystemInfoResponse.Capabilities capabilities, WorkflowImplementationOptions workflowImplOptions) -
WorkflowStateMachines
public WorkflowStateMachines(StatesMachinesCallback callbacks, Functions.Proc1<io.temporal.internal.statemachines.StateMachine> stateMachineSink)
-
-
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 inWorkflowTaskStateMachineonly 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
-
isContinueAsNewSuggested
public boolean isContinueAsNewSuggested() -
getSuggestContinueAsNewReasons
-
isTargetWorkerDeploymentVersionChanged
public boolean isTargetWorkerDeploymentVersionChanged() -
setReplaying
public void setReplaying(boolean replaying) -
setMessages
-
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
-
sendMessage
public void sendMessage(io.temporal.api.protocol.v1.Message message) -
takeMessages
-
tryUseSdkFlag
- Returns:
- True if the SDK flag is supported in this workflow execution
-
checkSdkFlag
- Returns:
- True if the SDK flag is set in the workflow execution
-
takeNewSdkFlags
-
sdkNameToWrite
- Returns:
- If we need to write the SDK name upon WFT completion, return it
-
sdkVersionToWrite
- Returns:
- If we need to write the SDK version upon WFT completion, return it
-
getLastStartedEventId
public long getLastStartedEventId() -
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 activitycallback- 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 attributesmetadata- user provided metadatacompletionCallback- 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 parametersstartedCallback- callback that is notified about child startcompletionCallback- 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 workflowcompletionCallback- 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 operationcompletionCallback- 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
-
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
-
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 idfunc- 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
-
handleLocalActivityCompletion
-
scheduleLocalActivityTask
public Functions.Proc scheduleLocalActivityTask(ExecuteLocalActivityParameters parameters, Functions.Proc2<Optional<io.temporal.api.common.v1.Payloads>, LocalActivityCallback.LocalActivityFailedException> callback)
-