node-sagas
Version:
Library for handling distributed transactions in the microservices architecture
30 lines • 803 B
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const factory_1 = require("./factory");
class SagaBuilder {
constructor() {
this.steps = [];
this.factory = new factory_1.default();
}
setFactory(factory) {
this.factory = factory;
}
step(name = '') {
this.currentStep = this.factory.createStep(name);
this.steps.push(this.currentStep);
return this;
}
invoke(method) {
this.currentStep.setInvocation(method);
return this;
}
withCompensation(method) {
this.currentStep.setCompensation(method);
return this;
}
build() {
return this.factory.createSaga(this.steps);
}
}
exports.SagaBuilder = SagaBuilder;
//# sourceMappingURL=saga-builder.js.map