{"id":20826732,"url":"https://github.com/cedrickchee/raft","last_synced_at":"2025-03-12T07:23:40.743Z","repository":{"id":138118607,"uuid":"354891138","full_name":"cedrickchee/raft","owner":"cedrickchee","description":"Raft algo","archived":false,"fork":false,"pushed_at":"2021-04-05T16:03:43.000Z","size":215,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-18T17:49:35.936Z","etag":null,"topics":["educational-project","golang","raft-consensus-algorithm"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cedrickchee.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":"2021-04-05T16:03:10.000Z","updated_at":"2024-11-01T11:31:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"d65aea6a-7ab9-485c-872d-2704543e8e51","html_url":"https://github.com/cedrickchee/raft","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrickchee%2Fraft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrickchee%2Fraft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrickchee%2Fraft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrickchee%2Fraft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cedrickchee","download_url":"https://codeload.github.com/cedrickchee/raft/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243174013,"owners_count":20248217,"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":["educational-project","golang","raft-consensus-algorithm"],"created_at":"2024-11-17T23:09:53.517Z","updated_at":"2025-03-12T07:23:40.731Z","avatar_url":"https://github.com/cedrickchee.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# :rowboat: Raft\n\nThis is an instructional implementation of the Raft distributed consensus\nalgorithm in Go. It's accompanied by a series of blog posts:\n\n* [Part 0: Introduction](https://eli.thegreenplace.net/2020/implementing-raft-part-0-introduction/)\n* [Part 1: Elections](https://eli.thegreenplace.net/2020/implementing-raft-part-1-elections/)\n* [Part 2: Commands and log replication](https://eli.thegreenplace.net/2020/implementing-raft-part-2-commands-and-log-replication/)\n* [Part 3: Persistence and optimizations](https://eli.thegreenplace.net/2020/implementing-raft-part-3-persistence-and-optimizations/)\n\nEach of the `partN` directories in this repository is the complete source code\nfor Part N of the blog post series (except Part 0, which is introductory and has\nno code). There is a lot of duplicated code between the different `partN`\ndirectories - this is a conscious design decision. Rather than abstracting and\nreusing parts of the implementation, I opted for keeping the code as simple\nas possible. Each directory is completely self contained and can be read and\nundestood in isolation. Using a graphical diff tool to see the deltas between\nthe parts can be instructional.\n\n## How to use this repository\n\nYou can read the code, but I'd also encourage you to run tests and observe the\nlogs they print out. The repository contains a useful tool for visualizing\noutput. Here's a complete usage example:\n\n```\n$ cd part1\n$ go test -v -race -run TestElectionFollowerComesBack |\u0026 tee /tmp/raftlog\n... logging output\n... test should PASS\n$ go run ../tools/raft-testlog-viz/main.go \u003c /tmp/raftlog\nPASS TestElectionFollowerComesBack map[0:true 1:true 2:true TEST:true] ; entries: 150\n... Emitted file:///tmp/TestElectionFollowerComesBack.html\n\nPASS\n```\n\nNow open `file:///tmp/TestElectionFollowerComesBack.html` in your browser.\nYou should see something like this:\n\n![Image of log browser](https://github.com/eliben/raft/blob/master/raftlog-screenshot.png)\n\nScroll and read the logs from the servers, noticing state changes (highlighted\nwith colors). Feel free to add your own `cm.dlog(...)` calls to the code to\nexperiment and print out more details.\n\n## Changing and testing the code\n\nEach `partN` directory is completely independent of the others, and is its own\nGo module. The Raft code itself has no external dependencies; the only `require`\nin its `go.mod` is for a package that enables goroutine leak testing - it's only\nused in tests.\n\nTo work on `part2`, for example:\n\n```\n$ cd part2\n... make code changes\n$ go test -race ./...\n```\n\nDepending on the part and your machine, the tests can take up to a minute to\nrun. Feel free to enable verbose logging with ``-v``, and/or used the provided\n``dotest.sh`` script to run specific tests with log visualization.\n\n## Contributing\n\nI'm interested in hearing your opinion or suggestions for the code in this\nrepository. Feel free to open an issue if something is unclear, or if you think\nyou found a bug. Code contributions through PRs are welcome as well.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcedrickchee%2Fraft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcedrickchee%2Fraft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcedrickchee%2Fraft/lists"}