Within our callbacks we could add single CallbackContext argument that holds references to session & extensions, along with Saga data structure. Within callbacks user can add saga steps that in case of failure will revert those actions from last step.
Each step has action field and optional compensating_action in case of failure. They are both futures that are evaluated once callbacks action is triggered.
Current Problems:
While all steps are rolled back, main operation is not e.g. if user uses ctx.saga in before_update and after_update we would rollback everything that is defined within compensating_action but user would have to rollback update itself as we can not know the state of model before update.
Within our callbacks we could add single
CallbackContext
argument that holds references to session & extensions, along with Saga data structure. Within callbacks user can add saga steps that in case of failure will revert those actions from last step.Here is sample from nodecosmos:
Each step has
action
field and optionalcompensating_action
in case of failure. They are both futures that are evaluated once callbacks action is triggered.Current Problems:
ctx.saga
inbefore_update
andafter_update
we would rollback everything that is defined withincompensating_action
but user would have to rollbackupdate
itself as we can not know the state of model before update.