This is a repository for the
node-sagas is a convenient library for managing data consistency in a microservice architecture.
It helps create distributed transaction across services.
A distinctive characteristic of the microservice architecture is that in order to ensure loose coupling each service’s data is private. Unlike in a monolithic application, you no longer have a single database that any module of the application can update. As a result, one of the key challenges that you will face is maintaining data consistency across services.
Please read more about saga pattern.
Installing / Getting started
This module is installed via npm::
npm i --save node-sagas
This package provides you with main classes for creating sagas.
The first main class is
;;.step'Create order'.invoke.withCompensation.step'Reserve credit'.invoke.step'Approve order'.invoke.build;;trycatch e
A step could be defined using
step() method, for each step you can set an action for a positive
invoke() method. Also for each step, you can define compensation action with
SagaBuilder class use generic class for the handler's params:
That class represents scope with params between the steps. Also, an instance of that class will be returned after the saga success execution.
The article on Medium with a practical example will be prepared soon.
The code in this project is licensed under MIT license.