Open szoio opened 5 years ago
It should be reasonably straightforward to implement cancellation logic.
There would need to be three additional saga states,
CancelationPending,
InCancelation,
Cancelled
with exactly the same semantics as the failure states. Maybe they can be combined. i.e. cancellation is a special form of failure.
Also there would need to be a Cancelled
saga action, but the only time this would ever be reached is if an action is cancelled mid flight, or if the natural retry https://github.com/simplesourcing/simplesagas/issues/19 flow is halted.
Probably more work would be needed on the client side - i.e. would it simply publish a saga transition event? That would be quite straightforward and wouldn't need any confirmation, as the usual saga response mechanism would take over.
Simple option: A saga can be cancelled but any actions that are currently running carry on running to termination. At that point the saga goes into cancel mode, and all completed actions are undone, similar to failure mode.
More complex option: Enable saga actions to be cancelled in mid flight. Once all currently running saga are have cancelled, start the process of undoing all the completed sagas.