Nebo15 / sage

A dependency-free tool to run distributed transactions in Elixir, inspired by Sagas pattern.
MIT License
912 stars 40 forks source link

Allows users to pass in their own Supervisor for async steps #78

Closed Adzz closed 1 year ago

Adzz commented 1 year ago

Imagine an app called Blog that uses Sage.

Currently Sage allows async steps that spin up a task supervised under Sage.AsyncTransactionSupervisor. Because Sage is a dep of Blog, on shutdown Blog will shutdown before Sage does.

That means if an async step interacts with a process under Blog's supervision tree and you are using some sort of rolling deploy you can enter the following scenario:

Blog starts async task
Sage starts doing that task
Blog shuts down
Sage tries to interact with a process in Blog and can't - so it crashes / errors.

Possible Solutions

Make Sage a library and allow users to start it themselves?
Allow the user to pass in their own supervisor under which it can start the async steps.

This PR does 2

Adzz commented 1 year ago

Closed in #77