UNPKG

node-sagas

Version:

Library for handling distributed transactions in the microservices architecture

21 lines 586 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class SagaFlow { constructor(steps = []) { this.compensationSteps = []; this.steps = steps; } async invoke(params) { for (const step of this.steps) { this.compensationSteps.push(step); await step.invoke(params); } } async compensate(params) { for (const step of this.compensationSteps.reverse()) { await step.compensate(params); } } } exports.SagaFlow = SagaFlow; //# sourceMappingURL=saga-flow.js.map