Skip to content

An implementation of the SAGA pattern using event driven architecture, created within a single nodejs process.

License

Notifications You must be signed in to change notification settings

damiancipolat/Node-event-saga

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node-event-saga

A custom implementation of the SAGA pattern using event driven architecture, created within a single nodejs process.

In this scenario the event bus is a Event Emitter into a nodejs process, in more complex project the bus will be sqs or sns in AWS. This project are only node.js modules and a scaffolding for more realistics scenarios will be necesary to add an api rest interface.

The Fail feature or the saga is only present in some events, in a real situation all the request should have it.

Events diagram

In this diagram I show how a transaction is done through different messages. For each operation two types of SUCCESS and FAIL messages are issued, in the case of FAIL status updates are applied to maintain consistency.

Note:

For this example, I will use for mock the Order, Notification and Payment service the web mocky.io to make fake but real request.

Events dictionary

Events name with description.

  • ORDER_CREATED: Initial event of the payment flow.
  • ORDER_CREATED_SUCCESS: Sucess order creation event.
  • ORDER_CREATED_FAIL: Order creaation error.
  • PAYMENT_FAIL: Error in process payment.
  • PAYMENT_SUCCESS: Payment succeffull.
  • FLOW_END: Send email with the bill and finish the flow.

To run:

npm install
node app.js

Readings:

About

An implementation of the SAGA pattern using event driven architecture, created within a single nodejs process.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published