Class WorkflowStateMachines
- java.lang.Object
-
- io.temporal.internal.statemachines.WorkflowStateMachines
-
public final class WorkflowStateMachines extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description WorkflowStateMachines(StatesMachinesCallback callbacks)
WorkflowStateMachines(StatesMachinesCallback callbacks, Functions.Proc1<io.temporal.internal.statemachines.StateMachine> stateMachineSink)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancelWorkflow()
void
completeWorkflow(java.util.Optional<io.temporal.api.common.v1.Payloads> workflowOutput)
void
continueAsNewWorkflow(io.temporal.api.command.v1.ContinueAsNewWorkflowExecutionCommandAttributes attributes)
long
currentTimeMillis()
void
failWorkflow(io.temporal.api.failure.v1.Failure failure)
long
getCurrentStartedEventId()
long
getLastStartedEventId()
void
getVersion(java.lang.String changeId, int minSupported, int maxSupported, Functions.Proc2<java.lang.Integer,java.lang.RuntimeException> callback)
void
handleEvent(io.temporal.api.history.v1.HistoryEvent event, boolean hasNextEvent)
Handle a single event from the workflow history.void
handleLocalActivityCompletion(LocalActivityResult laCompletion)
boolean
isReplaying()
void
mutableSideEffect(java.lang.String id, Functions.Func1<java.util.Optional<io.temporal.api.common.v1.Payloads>,java.util.Optional<io.temporal.api.common.v1.Payloads>> func, Functions.Proc1<java.util.Optional<io.temporal.api.common.v1.Payloads>> callback)
java.util.Random
newRandom()
Functions.Proc
newTimer(io.temporal.api.command.v1.StartTimerCommandAttributes attributes, Functions.Proc1<io.temporal.api.history.v1.HistoryEvent> completionCallback)
Creates a new timer state machinejava.util.UUID
randomUUID()
void
requestCancelExternalWorkflowExecution(io.temporal.api.command.v1.RequestCancelExternalWorkflowExecutionCommandAttributes attributes, Functions.Proc2<java.lang.Void,java.lang.RuntimeException> completionCallback)
Functions.Proc
scheduleActivityTask(ExecuteActivityParameters attributes, Functions.Proc2<java.util.Optional<io.temporal.api.common.v1.Payloads>,io.temporal.api.failure.v1.Failure> callback)
Functions.Proc
scheduleLocalActivityTask(ExecuteLocalActivityParameters parameters, Functions.Proc2<java.util.Optional<io.temporal.api.common.v1.Payloads>,LocalActivityCallback.LocalActivityFailedException> callback)
void
setReplaying(boolean replaying)
void
setWorklfowStartedEventId(long workflowTaskStartedEventId)
void
sideEffect(Functions.Func<java.util.Optional<io.temporal.api.common.v1.Payloads>> func, Functions.Proc1<java.util.Optional<io.temporal.api.common.v1.Payloads>> callback)
Functions.Proc
signalExternalWorkflowExecution(io.temporal.api.command.v1.SignalExternalWorkflowExecutionCommandAttributes attributes, Functions.Proc2<java.lang.Void,io.temporal.api.failure.v1.Failure> completionCallback)
Functions.Proc
startChildWorkflow(StartChildWorkflowExecutionParameters parameters, Functions.Proc2<io.temporal.api.common.v1.WorkflowExecution,java.lang.Exception> startedCallback, Functions.Proc2<java.util.Optional<io.temporal.api.common.v1.Payloads>,java.lang.Exception> completionCallback)
Creates a new child state machinejava.util.List<io.temporal.api.command.v1.Command>
takeCommands()
java.util.List<ExecuteLocalActivityParameters>
takeLocalActivityRequests()
void
upsertSearchAttributes(io.temporal.api.common.v1.SearchAttributes attributes)
-
-
-
Constructor Detail
-
WorkflowStateMachines
public WorkflowStateMachines(StatesMachinesCallback callbacks)
-
WorkflowStateMachines
public WorkflowStateMachines(StatesMachinesCallback callbacks, Functions.Proc1<io.temporal.internal.statemachines.StateMachine> stateMachineSink)
-
-
Method Detail
-
setWorklfowStartedEventId
public void setWorklfowStartedEventId(long workflowTaskStartedEventId)
- Parameters:
workflowTaskStartedEventId
- eventId of the workflowTask that was picked up by a worker and triggered an execution. Used inWorkflowTaskStateMachine
only to understand that this workflow task will not have a matching closing event and needs to be executed.
-
getCurrentStartedEventId
public long getCurrentStartedEventId()
-
setReplaying
public void setReplaying(boolean replaying)
-
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 java.util.List<io.temporal.api.command.v1.Command> takeCommands()
-
getLastStartedEventId
public long getLastStartedEventId()
-
scheduleActivityTask
public Functions.Proc scheduleActivityTask(ExecuteActivityParameters attributes, Functions.Proc2<java.util.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, Functions.Proc1<io.temporal.api.history.v1.HistoryEvent> completionCallback)
Creates a new timer state machine- Parameters:
attributes
- timer command attributescompletionCallback
- 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,java.lang.Exception> startedCallback, Functions.Proc2<java.util.Optional<io.temporal.api.common.v1.Payloads>,java.lang.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
-
signalExternalWorkflowExecution
public Functions.Proc signalExternalWorkflowExecution(io.temporal.api.command.v1.SignalExternalWorkflowExecutionCommandAttributes attributes, Functions.Proc2<java.lang.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<java.lang.Void,java.lang.RuntimeException> completionCallback)
- Parameters:
attributes
- attributes to use to cancel external workflowcompletionCallback
- one of ExternalWorkflowExecutionCancelRequestedEvent,
-
upsertSearchAttributes
public void upsertSearchAttributes(io.temporal.api.common.v1.SearchAttributes attributes)
-
completeWorkflow
public void completeWorkflow(java.util.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 java.util.UUID randomUUID()
-
newRandom
public java.util.Random newRandom()
-
sideEffect
public void sideEffect(Functions.Func<java.util.Optional<io.temporal.api.common.v1.Payloads>> func, Functions.Proc1<java.util.Optional<io.temporal.api.common.v1.Payloads>> callback)
-
mutableSideEffect
public void mutableSideEffect(java.lang.String id, Functions.Func1<java.util.Optional<io.temporal.api.common.v1.Payloads>,java.util.Optional<io.temporal.api.common.v1.Payloads>> func, Functions.Proc1<java.util.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 void getVersion(java.lang.String changeId, int minSupported, int maxSupported, Functions.Proc2<java.lang.Integer,java.lang.RuntimeException> callback)
-
takeLocalActivityRequests
public java.util.List<ExecuteLocalActivityParameters> takeLocalActivityRequests()
-
handleLocalActivityCompletion
public void handleLocalActivityCompletion(LocalActivityResult laCompletion)
-
scheduleLocalActivityTask
public Functions.Proc scheduleLocalActivityTask(ExecuteLocalActivityParameters parameters, Functions.Proc2<java.util.Optional<io.temporal.api.common.v1.Payloads>,LocalActivityCallback.LocalActivityFailedException> callback)
-
-