stavalfi / jstream

Represent graphs, differently https://stavalfi.github.io/jstream/
2 stars 0 forks source link

knowing if a flow function succeed or failed during cancellation function invocation #15

Closed stavalfi closed 5 years ago

stavalfi commented 5 years ago

2

The Limitation

There may be a situation where the flow function finished (succeed or failed), and the self-resolve action wasn't processed yet. During this time there is a cancellation action for the workflow. When I invoke the cancellation function, the user can't know if the flow function executed or not because the self-resolve action wasn't processed yet.

Implications

During an execution of a cancellation function, the user MUST know which flow-functions finished (succeed or failed) and which didn't execute at all yet in that workflow. If the flow function run or not, is critical information that his logic will be based upon.

Current Code

https://github.com/stavalfi/workflow/blob/62d56ef870983c496797ffc9ca406352577ab0bc/src/reducer/createReducer.js#L191

Cmd.run(functions.flows[actionToTrigger.flowName].task, {
                successActionCreator: () => actionToTrigger,
                args: [action.workflowId]
            });

By the docs of redux-loop, the successActionCreator will be dispatched in async mode.

Possible Solution

forceSync ensures that the successActionCreator will be dispatched sync and not async (If I understand correctly).

Cmd.run(functions.flows[actionToTrigger.flowName].task, {
                successActionCreator: () => actionToTrigger,
                args: [action.workflowId],
                forceSync: true
            })

Open Questions:

stavalfi commented 5 years ago

it is irrelevant for v2. this feature will be implemented by the user.