iamolegga / nestjs-saga

Implementation of saga pattern for NestJS
MIT License
21 stars 0 forks source link

[QUESTION] How can one use this lib as a base for Saga design pattern in microservices? #505

Closed kasir-barati closed 1 week ago

kasir-barati commented 2 weeks ago

Question

I was reading this repo and the one that its origin too but could not figure it out on my own, therefore here I am. I wanna implement Saga design pattern in microservices arch and know that I can use this lib as a base but I need a bit more context as in how and where am I supposed to define which service is where and how my Saga class can send those commands to each service?

I also realized that this kind of implementation has a potential threat to it, if server restarts it will loss all the sagas that were in process, that is also something I like to know about, is there a solution to it? I guess I could have just stored the whole process in a table in a DBMS.

Any kind of hint, similar work, blog post, or other forms of content that can prove beneficial?

iamolegga commented 1 week ago

I'm using it in a simple way without any state saving and restoring between restarts: in each step we just call rpc or send events for other microservices and that's it.

If you need something more I would suggest to look at ready to use orchestrators (like https://temporal.io/ or similars) instead of building your own.

kasir-barati commented 1 week ago

Hmm, thanks @iamolegga for the link. But I will be really happy if I could use some lib to implement it in NestJS/NodeJS. Do you know any resource, repo or lib that I can read or study to gain a better understanding of its building blocks and how I can implement orchestrator-based coordinator in my NestJS microservices app?