Saga Master is a Saga Orchestrator whose sole purpose is to manage transactions between microservices. It follows Saga Framework and can be easily integration into an existing environment without major architectural constraints.
-
Clone the repository:
git clone https://github.com/blazenn2/Saga-Master cd yourproject
-
Install dependencies:
npm install -f
-
Set up environment variables: Create a
.env
file in the root directory of your project and add the necessary environment variables. You can refer to.env.example
for the required variables.
To build Docker Image use the following command:
bash docker build -t saga-master -f dockerfile .
The dockerfile contains all the necessary environment variables. Adjust it accordingly to your requirements.
-
Start the server:
npm start
-
The server will be running at:
http://localhost:8888
To run the Docker Image, use the below command:
docker run -it --rm --name saga-master -p {port_mapping} saga-master:latest
- URL:
/setup
- Method:
POST
- Description: Sets up the saga master.
- Example_Body:
{ "url": "create-payment-intend", "setup": [ { "communicateType": "REST", "apiType": "POST", "apiUrl": "http://localhost:8080/api/invoices", "compensateApiUrl": "http://localhost:8080/api/invoices", "compensateApiType": "DELETE", "compensatePathVariable": "id", "serviceName": "order", "sendResponseToAPI": false, "triggerCompensate": true }, { "communicateType": "REST", "apiType": "POST", "apiUrl": "http://localhost:8000/api/products", "compensateApiUrl": "http://localhost:8000/api/products", "compensateApiType": "DELETE", "compensatePathVariable": "id", "serviceName": "inventory", "sendResponseToAPI": true, "triggerCompensate": true }, { "communicateType": "REST", "apiType": "POST", "apiUrl": "http://localhost/payment-php/create-payment.php", "compensateApiUrl": "http://localhost/payment-php/create-payment-rollback.php", "compensateApiType": "POST", "compensatePathVariable": "paymentId", "serviceName": "payment", "sendResponseToAPI": true, "triggerCompensate": true }, { "communicateType": "REST", "apiType": "POST", "apiUrl": "http://localhost:8089/notifications", "compensateApiUrl": "", "serviceName": "notify", "sendResponseToAPI": true, "triggerCompensate": false } ] }
- URL:
/setup/:url
- Method:
PUT
- Description: Updates an existing setup.
- URL:
/setup/:url
- Method:
DELETE
- Description: Deletes an existing setup.
- URL:
/setup
- Method:
GET
- Description: Retrieves the current setup.
- URL:
/trigger/:url
- Method:
POST
- Description: Triggers the orchestrator against the setup done in the setup process.
Configuration options can be set using environment variables. Below are the key configuration options:
PORT
: Port number on which the server will run (default:8888
).
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.