Class StateDecision


  • @Immutable
    public abstract class StateDecision
    extends java.lang.Object
    • Constructor Detail

      • StateDecision

        public StateDecision()
    • Method Detail

      • getWorkflowConditionalClose

        public abstract java.util.Optional<InternalConditionalClose> getWorkflowConditionalClose()
      • getNextStates

        public abstract java.util.List<StateMovement> getNextStates()
      • 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 completion
        internalChannelName - the internal channel name for checking emptiness
        orElseStateMovements - 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 completion
        signalChannelName - the signal channel name for checking emptiness
        orElseStateMovements - 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 - required
        stateInput - optional, can be null
        stateOptionsOverride - 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 - required
        stateInput - 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 state
        stateInput - optional, can be null. Input for next state
        stateOptionsOverride - 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