https://github.com/chassisframework/two_phase_commit
(WIP) Two Phase Commit state machine for Elixir
https://github.com/chassisframework/two_phase_commit
2pc distributed-systems elixir two-phase-commit
Last synced: 4 months ago
JSON representation
(WIP) Two Phase Commit state machine for Elixir
- Host: GitHub
- URL: https://github.com/chassisframework/two_phase_commit
- Owner: chassisframework
- Created: 2020-10-19T23:39:46.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-01-02T07:48:03.000Z (about 4 years ago)
- Last Synced: 2025-09-20T16:00:29.959Z (5 months ago)
- Topics: 2pc, distributed-systems, elixir, two-phase-commit
- Language: Elixir
- Homepage:
- Size: 14.6 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TwoPhaseCommit
*WORK IN PROGRESS*
[Two Phase Commit](https://en.wikipedia.org/wiki/Two-phase_commit_protocol) state machine model.
You can use the state machine to build a transaction coordinator, there's a bare-bones GenServer [implementation](example/lib/coordinator.ex) included.
## Installation
The package can be installed by adding `two_phase_commit` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:two_phase_commit, "~> 0.1.0"}
]
end
```
The docs can be found at [https://hexdocs.pm/two_phase_commit](https://hexdocs.pm/two_phase_commit).
## State Machine Diagram
```
+
|
| 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 |
| |
+---------------+
```