Nebo15 / sage

A dependency-free tool to run distributed transactions in Elixir, inspired by Sagas pattern.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allows users to pass in their own Supervisor for async steps

Adzz opened this issue · comments

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

Closed in #77