{"id":29116371,"url":"https://github.com/vadiminshakov/committer","last_synced_at":"2025-06-29T11:13:54.966Z","repository":{"id":56610366,"uuid":"284433715","full_name":"vadiminshakov/committer","owner":"vadiminshakov","description":"Two-phase (2PC) and three-phase (3PC) protocols implementaion in Golang","archived":false,"fork":false,"pushed_at":"2025-06-21T19:48:33.000Z","size":9441,"stargazers_count":38,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-21T20:31:27.887Z","etag":null,"topics":["2pc","3pc","distributed-systems","three-phase-commit","two-phase-commit"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vadiminshakov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-08-02T09:50:12.000Z","updated_at":"2025-06-21T19:48:37.000Z","dependencies_parsed_at":"2022-08-15T21:50:51.051Z","dependency_job_id":"6a5cbd7d-ba75-4728-97c1-1ac50d0a3c87","html_url":"https://github.com/vadiminshakov/committer","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/vadiminshakov/committer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadiminshakov%2Fcommitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadiminshakov%2Fcommitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadiminshakov%2Fcommitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadiminshakov%2Fcommitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vadiminshakov","download_url":"https://codeload.github.com/vadiminshakov/committer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadiminshakov%2Fcommitter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262581513,"owners_count":23331925,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2pc","3pc","distributed-systems","three-phase-commit","two-phase-commit"],"created_at":"2025-06-29T11:13:35.778Z","updated_at":"2025-06-29T11:13:54.941Z","avatar_url":"https://github.com/vadiminshakov.png","language":"Go","funding_links":[],"categories":["Distributed Systems","分布式系统"],"sub_categories":["Search and Analytic Databases","检索及分析资料库"],"readme":"![tests](https://github.com/vadiminshakov/committer/actions/workflows/tests.yml/badge.svg?branch=master)\n[![Go Reference](https://pkg.go.dev/badge/github.com/vadiminshakov/committer.svg)](https://pkg.go.dev/github.com/vadiminshakov/committer)\n[![Go Report Card](https://goreportcard.com/badge/github.com/vadiminshakov/committer)](https://goreportcard.com/report/github.com/vadiminshakov/committer)\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://github.com/vadiminshakov/committer/blob/master/committer.png\" alt=\"Committer Logo\"\u003e\n\u003c/p\u003e\n\n# **Committer**\n\n**Committer** is a Go implementation of the **Two-Phase Commit (2PC)** and **Three-Phase Commit (3PC)** protocols for distributed systems.\n\n## **Architecture**\n\nThe system consists of two types of nodes: **Coordinator** and **Followers**.\nThe **Coordinator** is responsible for initiating and managing the commit protocols (2PC or 3PC), while the **Followers** (or cohorts) participate in the protocol by responding to the coordinator's requests.\nThe communication between nodes is handled using gRPC, and the state of each node is managed using a state machine.\n\n## **Key Features**\n\n- **2PC and 3PC support**: Implements two widely used consensus protocols for distributed transactions.\n- **Persistence**: Uses **BadgerDB** and WAL for reliable data storage and transaction logs.\n- **Configurable**: All options can be specified using command-line flags.\n- **Hooks for validation**: Custom logic can be injected during **Propose** and **Commit** stages.\n- **gRPC-based communication**: Efficient inter-node communication using gRPC.\n\n## **Configuration**\n\nAll configuration parameters can be set using command-line flags:\n\n| **Flag**       | **Description**                                          | **Default**         | **Example**                          |\n|-----------------|---------------------------------------------------------|---------------------|-------------------------------------|\n| `role`         | Node role: `coordinator` or `follower`                  | `follower`          | `-role=coordinator`                 |\n| `nodeaddr`     | Address of the current node                             | `localhost:3050`    | `-nodeaddr=localhost:3051`          |\n| `coordinator`  | Coordinator address (required for followers)            | `\"\"`                | `-coordinator=localhost:3050`       |\n| `committype`   | Commit protocol: `two-phase` or `three-phase`           | `three-phase`       | `-committype=two-phase`             |\n| `timeout`      | Timeout (ms) for unacknowledged messages (3PC only)     | `1000`              | `-timeout=500`                      |\n| `dbpath`       | Path to the BadgerDB database on the filesystem         | `./badger`          | `-dbpath=/tmp/badger`               |\n| `followers`    | Comma-separated list of follower addresses              | `\"\"`                | `-followers=localhost:3052,3053`    |\n| `whitelist`    | Comma-separated list of allowed hosts                   | `127.0.0.1`         | `-whitelist=192.168.0.1,192.168.0.2`|\n\n\n## **Usage**\n\n### **Running as a Follower**\n```bash\n./committer -role=follower -nodeaddr=localhost:3001 -committype=three-phase -timeout=1000 -dbpath=/tmp/badger/follower\n```\n\n### **Running as a Coordinator**\n```bash\n./committer -role=coordinator -nodeaddr=localhost:3000 -followers=localhost:3001 -committype=three-phase -timeout=1000 -dbpath=/tmp/badger/coordinator\n```\n\n## **Hooks**\n\nHooks allow you to add custom validation logic during the **Propose** and **Commit** stages.  \nA hook is a function that accepts `*pb.ProposeRequest` or `*pb.CommitRequest` and returns a boolean.\n\nExample hook implementation can be found [here](https://github.com/vadiminshakov/committer/blob/master/core/cohort/commitalgo/hooks/hooks.go).\n\nTo inject your own logic, replace the code in the hook file or in main.go with your custom validation and compile sources.\n\n## **Testing**\n\n### **Run Functional Tests**\n```bash\nmake tests\n```\n\n### **Testing with Example Client**\n1. Compile executables:\n\n```bash\nmake prepare\n```\n\n2. Run the coordinator:\n\n```bash\nmake run-example-coordinator\n```\n\n3. Run a follower in another terminal:\n\n```bash\nmake run-example-follower\n```\n\n4. Start the example client:\n\n```bash\ngo run ./examples/client/client.go\n```\n\n## **Contributions**\n\nContributions are welcome! Feel free to submit a PR or open an issue if you find bugs or have suggestions for improvement.\n\n## **License**\n\nThis project is licensed under the [Apache License](LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvadiminshakov%2Fcommitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvadiminshakov%2Fcommitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvadiminshakov%2Fcommitter/lists"}