WORK IN PROGRESS
Two Phase Commit state machine model.
You can use the state machine to build a transaction coordinator, there's a bare-bones GenServer implementation included.
The package can be installed by adding two_phase_commit
to your list of dependencies in mix.exs
:
def deps do
[
{:two_phase_commit, "~> 0.1.0"}
]
end
The docs can be found at https://hexdocs.pm/two_phase_commit.
+
|
| new/2
|
v
+-------+------+
+--+ |
add_participant/2 | | :interactive |
+->+ | aborted/2
+-------+------+
| +------+
| prepare/1 | |
v | v
+-------+------+ +----+------+---+ +---------------+
+--+ | aborted/2 | | rolled_back/2 | |
prepared/2 | | :voting +---------->+ :rolling_back +-------------->+ :aborted |
+->+ | | | | |
+-------+------+ +----+------+---+ +---------------+
| | ^
| prepared/2 | |
v +------+
+-------+-------+
+--+ | rolled_back/2
committed/2 | | :committing |
+->+ |
+-------+-------+
|
| committed/2
v
+-------+-------+
| |
| :committed |
| |
+---------------+