Package io.iworkflow.core
Class StateDecision
- java.lang.Object
-
- io.iworkflow.core.StateDecision
-
@Immutable public abstract class StateDecision extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description StateDecision()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static io.iworkflow.core.ImmutableStateDecision.Builderbuilder()static StateDecisiondeadEnd()static StateDecisionforceCompleteIfInternalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String internalChannelName, StateMovement... orElseStateMovements)Atomically force complete the workflow if internal channel is empty, otherwise trigger the state movements from the current thread This is important for use case that needs to ensure all the messages in the channel are processed before completing the workflow, otherwise messages will be lost.static <I> StateDecisionforceCompleteIfInternalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String internalChannelName, java.lang.Class<? extends WorkflowState<I>> orElseStateClass)static <I> StateDecisionforceCompleteIfInternalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String internalChannelName, java.lang.Class<? extends WorkflowState<I>> orElseStateClass, I stateInput)static <I> StateDecisionforceCompleteIfInternalChannelEmptyOrElse(java.lang.String internalChannelName, java.lang.Class<? extends WorkflowState<I>> orElseStateClass)static <I> StateDecisionforceCompleteIfInternalChannelEmptyOrElse(java.lang.String internalChannelName, java.lang.Class<? extends WorkflowState<I>> orElseStateClass, I stateInput)static StateDecisionforceCompleteIfSignalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String signalChannelName, StateMovement... orElseStateMovements)Atomically force complete the workflow if signal channel is empty, otherwise trigger the state movements from the current thread This is important for use case that needs to ensure all the messages in the channel are processed before completing the workflow, otherwise messages will be lost.static <I> StateDecisionforceCompleteIfSignalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String signalChannelName, java.lang.Class<? extends WorkflowState<I>> orElseStateClass)static <I> StateDecisionforceCompleteIfSignalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String signalChannelName, java.lang.Class<? extends WorkflowState<I>> orElseStateClass, I stateInput)static <I> StateDecisionforceCompleteIfSignalChannelEmptyOrElse(java.lang.String signalChannelName, java.lang.Class<? extends WorkflowState<I>> orElseStateClass)static <I> StateDecisionforceCompleteIfSignalChannelEmptyOrElse(java.lang.String signalChannelName, java.lang.Class<? extends WorkflowState<I>> orElseStateClass, I stateInput)static StateDecisionforceCompleteWorkflow()static StateDecisionforceCompleteWorkflow(java.lang.Object completionOutput)static StateDecisionforceFailWorkflow()static StateDecisionforceFailWorkflow(java.lang.Object completionOutput)abstract java.util.List<StateMovement>getNextStates()abstract java.util.Optional<InternalConditionalClose>getWorkflowConditionalClose()static StateDecisiongracefulCompleteWorkflow()static StateDecisiongracefulCompleteWorkflow(java.lang.Object completionOutput)static StateDecisionmultiNextStates(StateMovement... stateMovements)static StateDecisionmultiNextStates(java.lang.Class<? extends WorkflowState>... states)use other ones with a list of StateMovement to enable the WorkflowStateOptions overridingstatic StateDecisionmultiNextStates(java.lang.String... stateIds)use the other one with WorkflowState class param if the stateId is provided by default, to make your code cleaner or use other ones with a list of StateMovement to enable the WorkflowStateOptions overridingstatic StateDecisionmultiNextStates(java.util.List<StateMovement> stateMovements)static <I> StateDecisionsingleNextState(java.lang.Class<? extends WorkflowState<I>> stateClass)static <I> StateDecisionsingleNextState(java.lang.Class<? extends WorkflowState<I>> stateClass, I stateInput)static <I> StateDecisionsingleNextState(java.lang.Class<? extends WorkflowState<I>> stateClass, I stateInput, WorkflowStateOptions stateOptionsOverride)static StateDecisionsingleNextState(java.lang.String stateId)use the other one with WorkflowState class param if the stateId is provided by default, to make your code cleanerstatic StateDecisionsingleNextState(java.lang.String stateId, java.lang.Object stateInput, WorkflowStateOptions stateOptionsOverride)use the other one with WorkflowState class param if the stateId is provided by default, to make your code cleanerstatic StateDecisionsingleNextStateUntypedInput(java.lang.Class<? extends WorkflowState> stateClass, java.lang.Object stateInput)singleNextState as non-strongly typing required for input
-
-
-
Method Detail
-
getWorkflowConditionalClose
public abstract java.util.Optional<InternalConditionalClose> getWorkflowConditionalClose()
-
getNextStates
public abstract java.util.List<StateMovement> getNextStates()
-
deadEnd
public static StateDecision deadEnd()
-
builder
public static io.iworkflow.core.ImmutableStateDecision.Builder builder()
-
gracefulCompleteWorkflow
public static StateDecision gracefulCompleteWorkflow(java.lang.Object completionOutput)
-
gracefulCompleteWorkflow
public static StateDecision gracefulCompleteWorkflow()
-
forceCompleteWorkflow
public static StateDecision forceCompleteWorkflow(java.lang.Object completionOutput)
-
forceCompleteWorkflow
public static StateDecision forceCompleteWorkflow()
-
forceFailWorkflow
public static StateDecision forceFailWorkflow(java.lang.Object completionOutput)
-
forceFailWorkflow
public static StateDecision forceFailWorkflow()
-
forceCompleteIfInternalChannelEmptyOrElse
public static <I> StateDecision forceCompleteIfInternalChannelEmptyOrElse(java.lang.String internalChannelName, java.lang.Class<? extends WorkflowState<I>> orElseStateClass)
-
forceCompleteIfInternalChannelEmptyOrElse
public static <I> StateDecision forceCompleteIfInternalChannelEmptyOrElse(java.lang.String internalChannelName, java.lang.Class<? extends WorkflowState<I>> orElseStateClass, I stateInput)
-
forceCompleteIfInternalChannelEmptyOrElse
public static <I> StateDecision forceCompleteIfInternalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String internalChannelName, java.lang.Class<? extends WorkflowState<I>> orElseStateClass)
-
forceCompleteIfInternalChannelEmptyOrElse
public static <I> StateDecision forceCompleteIfInternalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String internalChannelName, java.lang.Class<? extends WorkflowState<I>> orElseStateClass, I stateInput)
-
forceCompleteIfInternalChannelEmptyOrElse
public static StateDecision forceCompleteIfInternalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String internalChannelName, StateMovement... orElseStateMovements)
Atomically force complete the workflow if internal channel is empty, otherwise trigger the state movements from the current thread This is important for use case that needs to ensure all the messages in the channel are processed before completing the workflow, otherwise messages will be lost. Without this atomic API, if user just check the channel emptiness in the State APIs, the channel may receive new messages during the execution of state APIs
Note that today this doesn't cover the case that internal messages are published from other State APIs yet. It's only for internal messages published from RPCs. If you do want to use other State APIs to publish messages to the channel at the same time, you can use persistence locking to ensure only the State APIs are not executed in parallel. See more in TODO https://github.com/indeedeng/iwf/issues/289- Parameters:
completionOutput- the output of workflow completioninternalChannelName- the internal channel name for checking emptinessorElseStateMovements- the state movements if channel is not empty- Returns:
- the decision
-
forceCompleteIfSignalChannelEmptyOrElse
public static <I> StateDecision forceCompleteIfSignalChannelEmptyOrElse(java.lang.String signalChannelName, java.lang.Class<? extends WorkflowState<I>> orElseStateClass)
-
forceCompleteIfSignalChannelEmptyOrElse
public static <I> StateDecision forceCompleteIfSignalChannelEmptyOrElse(java.lang.String signalChannelName, java.lang.Class<? extends WorkflowState<I>> orElseStateClass, I stateInput)
-
forceCompleteIfSignalChannelEmptyOrElse
public static <I> StateDecision forceCompleteIfSignalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String signalChannelName, java.lang.Class<? extends WorkflowState<I>> orElseStateClass)
-
forceCompleteIfSignalChannelEmptyOrElse
public static <I> StateDecision forceCompleteIfSignalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String signalChannelName, java.lang.Class<? extends WorkflowState<I>> orElseStateClass, I stateInput)
-
forceCompleteIfSignalChannelEmptyOrElse
public static StateDecision forceCompleteIfSignalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String signalChannelName, StateMovement... orElseStateMovements)
Atomically force complete the workflow if signal channel is empty, otherwise trigger the state movements from the current thread This is important for use case that needs to ensure all the messages in the channel are processed before completing the workflow, otherwise messages will be lost. Without this atomic API, if user just check the channel emptiness in the State APIs, the channel may receive new messages during the execution of state APIs- Parameters:
completionOutput- the output of workflow completionsignalChannelName- the signal channel name for checking emptinessorElseStateMovements- the state movements if channel is not empty- Returns:
- the decision
-
singleNextState
public static <I> StateDecision singleNextState(java.lang.Class<? extends WorkflowState<I>> stateClass, I stateInput, WorkflowStateOptions stateOptionsOverride)
- Type Parameters:
I- Class type of the WorkflowState input- Parameters:
stateClass- requiredstateInput- optional, can be nullstateOptionsOverride- optional, can be null. It is used to override the defined one in the State class- Returns:
- state decision
-
singleNextState
public static <I> StateDecision singleNextState(java.lang.Class<? extends WorkflowState<I>> stateClass, I stateInput)
- Type Parameters:
I- Class type of the WorkflowState input- Parameters:
stateClass- requiredstateInput- optional, can be null- Returns:
- state decision
-
singleNextStateUntypedInput
public static StateDecision singleNextStateUntypedInput(java.lang.Class<? extends WorkflowState> stateClass, java.lang.Object stateInput)
singleNextState as non-strongly typing required for input- Parameters:
stateClass- requiredstateInput- optional, can be null- Returns:
-
singleNextState
public static <I> StateDecision singleNextState(java.lang.Class<? extends WorkflowState<I>> stateClass)
- Type Parameters:
I- Class type of the WorkflowState input- Parameters:
stateClass- required- Returns:
- state decision
-
singleNextState
public static StateDecision singleNextState(java.lang.String stateId, java.lang.Object stateInput, WorkflowStateOptions stateOptionsOverride)
use the other one with WorkflowState class param if the stateId is provided by default, to make your code cleaner- Parameters:
stateId- required. StateId of next statestateInput- optional, can be null. Input for next statestateOptionsOverride- optional, can be null. It is used to override the defined one in the State class- Returns:
- state decision
-
singleNextState
public static StateDecision singleNextState(java.lang.String stateId)
use the other one with WorkflowState class param if the stateId is provided by default, to make your code cleaner- Parameters:
stateId- stateId of next state- Returns:
- state decision
-
multiNextStates
public static StateDecision multiNextStates(java.util.List<StateMovement> stateMovements)
- Parameters:
stateMovements- required- Returns:
- state decision
-
multiNextStates
public static StateDecision multiNextStates(StateMovement... stateMovements)
- Parameters:
stateMovements- required- Returns:
- state decision
-
multiNextStates
public static StateDecision multiNextStates(java.lang.String... stateIds)
use the other one with WorkflowState class param if the stateId is provided by default, to make your code cleaner or use other ones with a list of StateMovement to enable the WorkflowStateOptions overriding- Parameters:
stateIds- stateIds of next states- Returns:
- state decision
-
multiNextStates
public static StateDecision multiNextStates(java.lang.Class<? extends WorkflowState>... states)
use other ones with a list of StateMovement to enable the WorkflowStateOptions overriding- Parameters:
states- required- Returns:
- state decision
-
-