{"id":25600951,"url":"https://github.com/robjsliwa/raft-simple","last_synced_at":"2026-06-22T22:32:02.133Z","repository":{"id":277230638,"uuid":"931758362","full_name":"robjsliwa/raft-simple","owner":"robjsliwa","description":"Learning Raft Consensus Algorithm","archived":false,"fork":false,"pushed_at":"2025-02-19T01:52:49.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-21T15:50:46.824Z","etag":null,"topics":["go","raft","raft-consensus-algorithm"],"latest_commit_sha":null,"homepage":"https://medium.com/@robjsliwa_71070/learning-raft-consensus-algorithm-fd960f6c3605","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robjsliwa.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}},"created_at":"2025-02-12T20:05:31.000Z","updated_at":"2025-02-19T01:52:52.000Z","dependencies_parsed_at":"2025-02-14T11:31:18.472Z","dependency_job_id":null,"html_url":"https://github.com/robjsliwa/raft-simple","commit_stats":null,"previous_names":["robjsliwa/raft-simple"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/robjsliwa/raft-simple","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robjsliwa%2Fraft-simple","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robjsliwa%2Fraft-simple/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robjsliwa%2Fraft-simple/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robjsliwa%2Fraft-simple/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robjsliwa","download_url":"https://codeload.github.com/robjsliwa/raft-simple/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robjsliwa%2Fraft-simple/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34668500,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["go","raft","raft-consensus-algorithm"],"created_at":"2025-02-21T15:37:49.521Z","updated_at":"2026-06-22T22:32:02.109Z","avatar_url":"https://github.com/robjsliwa.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Raft Implementation in Go\n\nThis repository contains a simple Raft consensus implementation in Go, covered in the article:\n[Learning Raft Consensus Algorithm](https://medium.com/@robjsliwa_71070/learning-raft-consensus-algorithm-fd960f6c3605)\n\n# 📖 About\n\nRaft is a distributed consensus algorithm designed to be easier to understand than Paxos. It ensures a replicated state machine across multiple nodes. This implementation provides:\n- Leader Election 🏆 - Nodes elect a leader when one is unavailable.\n- Log Replication 📜 - The leader replicates logs to followers.\n- Client Command Handling 🎮 - The leader accepts commands and ensures they are applied to all nodes.\n\nThis implementation is not production-ready but serves as an educational tool to understand the fundamentals of Raft.\n\n# 🚀 Getting Started\n\n## Prerequisites\n- Go (1.18+ recommended)\n\n## 📦 Installation\n\nClone the repository:\n\n```bash\ngit clone https://github.com/your-username/raft-simple.git\ncd raft-simple\n```\n\nBuild the Raft node executable:\n\n```bash\ngo build -o raft-node main.go\n```\n\n## 🏃 Running the Raft Cluster\n\nYou can start multiple Raft nodes on different terminals.\n\nStarting 3 Raft Nodes\n\nEach node requires:\n- A unique ID\n- Its own address\n- A list of peer nodes\n\nStart Node 1\n\n```bash\n./raft-node -id=node1 -addr=127.0.0.1:8001 -peers=127.0.0.1:8002,127.0.0.1:8003\n```\n\nStart Node 2\n\n```bash\n./raft-node -id=node2 -addr=127.0.0.1:8002 -peers=127.0.0.1:8001,127.0.0.1:8003\n```\n\nStart Node 3\n\n```bash\n./raft-node -id=node3 -addr=127.0.0.1:8003 -peers=127.0.0.1:8001,127.0.0.1:8002\n```\n\nOnce the nodes are running, they will elect a leader automatically.\n\n## 🔍 Checking Node Status\n\nEach node provides an endpoint to check its state.\n\nQuery the Raft State\n\nRun:\n\n```bash\ncurl http://127.0.0.1:8001/raft/state | jq\n```\n\nExample output:\n```json\n{\n  \"id\": \"node1\",\n  \"term\": 5,\n  \"state\": \"Leader\",\n  \"commitIndex\": 3,\n  \"lastApplied\": 3,\n  \"log\": [\n    {\"term\": 3, \"command\": \"test1\"},\n    {\"term\": 3, \"command\": \"test2\"}\n  ],\n  \"peerAddresses\": [\"127.0.0.1:8002\", \"127.0.0.1:8003\"]\n}\n```\n\n## ✨ Sending Commands to Raft\n\nOnly the leader accepts commands. If a client sends a command to a follower, it will be rejected.\n\nSend a Command\n\n```bash\ncurl -X POST http://127.0.0.1:8001/client/commands -d '{\"command\": \"test1\"}'\n```\n\nResponse:\n\n```json\n{\"index\":0}\n```\n\nVerify Log Replication\n\nRun:\n\n```bash\ncurl http://127.0.0.1:8002/raft/state | jq\n```\n\nYou should see \"command\": \"test1\" replicated in the logs.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobjsliwa%2Fraft-simple","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobjsliwa%2Fraft-simple","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobjsliwa%2Fraft-simple/lists"}