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.Builder
builder()
static StateDecision
deadEnd()
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.static StateDecision
forceCompleteIfInternalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String internalChannelName, java.lang.Class<? extends WorkflowState> orElseStateClass)
static StateDecision
forceCompleteIfInternalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String internalChannelName, java.lang.Class<? extends WorkflowState> orElseStateClass, java.lang.Object stateInput)
static StateDecision
forceCompleteIfInternalChannelEmptyOrElse(java.lang.String internalChannelName, java.lang.Class<? extends WorkflowState> orElseStateClass)
static StateDecision
forceCompleteIfInternalChannelEmptyOrElse(java.lang.String internalChannelName, java.lang.Class<? extends WorkflowState> orElseStateClass, java.lang.Object stateInput)
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.static StateDecision
forceCompleteIfSignalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String signalChannelName, java.lang.Class<? extends WorkflowState> orElseStateClass)
static StateDecision
forceCompleteIfSignalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String signalChannelName, java.lang.Class<? extends WorkflowState> orElseStateClass, java.lang.Object stateInput)
static StateDecision
forceCompleteIfSignalChannelEmptyOrElse(java.lang.String signalChannelName, java.lang.Class<? extends WorkflowState> orElseStateClass)
static StateDecision
forceCompleteIfSignalChannelEmptyOrElse(java.lang.String signalChannelName, java.lang.Class<? extends WorkflowState> orElseStateClass, java.lang.Object stateInput)
static StateDecision
forceCompleteWorkflow()
static StateDecision
forceCompleteWorkflow(java.lang.Object completionOutput)
static StateDecision
forceFailWorkflow()
static StateDecision
forceFailWorkflow(java.lang.Object completionOutput)
abstract java.util.List<StateMovement>
getNextStates()
abstract java.util.Optional<InternalConditionalClose>
getWorkflowConditionalClose()
static StateDecision
gracefulCompleteWorkflow()
static StateDecision
gracefulCompleteWorkflow(java.lang.Object completionOutput)
static StateDecision
multiNextStates(StateMovement... stateMovements)
static StateDecision
multiNextStates(java.lang.Class<? extends WorkflowState>... states)
use other ones with a list of StateMovement to enable the WorkflowStateOptions overridingstatic 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 overridingstatic StateDecision
multiNextStates(java.util.List<StateMovement> stateMovements)
static StateDecision
singleNextState(java.lang.Class<? extends WorkflowState> stateClass)
static StateDecision
singleNextState(java.lang.Class<? extends WorkflowState> stateClass, java.lang.Object stateInput)
static StateDecision
singleNextState(java.lang.Class<? extends WorkflowState> stateClass, java.lang.Object stateInput, WorkflowStateOptions stateOptionsOverride)
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 cleanerstatic 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
-
-
-
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 StateDecision forceCompleteIfInternalChannelEmptyOrElse(java.lang.String internalChannelName, java.lang.Class<? extends WorkflowState> orElseStateClass)
-
forceCompleteIfInternalChannelEmptyOrElse
public static StateDecision forceCompleteIfInternalChannelEmptyOrElse(java.lang.String internalChannelName, java.lang.Class<? extends WorkflowState> orElseStateClass, java.lang.Object stateInput)
-
forceCompleteIfInternalChannelEmptyOrElse
public static StateDecision forceCompleteIfInternalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String internalChannelName, java.lang.Class<? extends WorkflowState> orElseStateClass)
-
forceCompleteIfInternalChannelEmptyOrElse
public static StateDecision forceCompleteIfInternalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String internalChannelName, java.lang.Class<? extends WorkflowState> orElseStateClass, java.lang.Object 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 StateDecision forceCompleteIfSignalChannelEmptyOrElse(java.lang.String signalChannelName, java.lang.Class<? extends WorkflowState> orElseStateClass)
-
forceCompleteIfSignalChannelEmptyOrElse
public static StateDecision forceCompleteIfSignalChannelEmptyOrElse(java.lang.String signalChannelName, java.lang.Class<? extends WorkflowState> orElseStateClass, java.lang.Object stateInput)
-
forceCompleteIfSignalChannelEmptyOrElse
public static StateDecision forceCompleteIfSignalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String signalChannelName, java.lang.Class<? extends WorkflowState> orElseStateClass)
-
forceCompleteIfSignalChannelEmptyOrElse
public static StateDecision forceCompleteIfSignalChannelEmptyOrElse(java.lang.Object completionOutput, java.lang.String signalChannelName, java.lang.Class<? extends WorkflowState> orElseStateClass, java.lang.Object 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 StateDecision singleNextState(java.lang.Class<? extends WorkflowState> stateClass, java.lang.Object stateInput, WorkflowStateOptions stateOptionsOverride)
- 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 StateDecision singleNextState(java.lang.Class<? extends WorkflowState> stateClass, java.lang.Object stateInput)
- Parameters:
stateClass
- requiredstateInput
- optional, can be null- Returns:
- state decision
-
singleNextState
public static StateDecision singleNextState(java.lang.Class<? extends WorkflowState> stateClass)
- 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
-
-