{"id":26729023,"url":"https://github.com/ifoxhz/raft-nginx","last_synced_at":"2026-07-19T04:37:42.464Z","repository":{"id":283048550,"uuid":"950505672","full_name":"ifoxhz/raft-nginx","owner":"ifoxhz","description":"raft-nginx 是利用hashicorp的raft 协议，实现一个边缘计算nginx网关的集群框架","archived":false,"fork":false,"pushed_at":"2025-06-11T08:38:56.000Z","size":315,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-23T17:02:59.777Z","etag":null,"topics":["distributed-computing","edge","edge-computing","nginx-proxy","raft"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ifoxhz.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-18T09:13:51.000Z","updated_at":"2025-06-11T08:39:00.000Z","dependencies_parsed_at":"2025-06-11T09:30:41.848Z","dependency_job_id":"4ff98f95-1377-45e7-9e5e-78227470b54c","html_url":"https://github.com/ifoxhz/raft-nginx","commit_stats":null,"previous_names":["ifoxhz/raft-nginx"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ifoxhz/raft-nginx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ifoxhz%2Fraft-nginx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ifoxhz%2Fraft-nginx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ifoxhz%2Fraft-nginx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ifoxhz%2Fraft-nginx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ifoxhz","download_url":"https://codeload.github.com/ifoxhz/raft-nginx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ifoxhz%2Fraft-nginx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35642105,"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-07-19T02:00:06.923Z","response_time":112,"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":["distributed-computing","edge","edge-computing","nginx-proxy","raft"],"created_at":"2025-03-27T22:38:37.439Z","updated_at":"2026-07-19T04:37:42.447Z","avatar_url":"https://github.com/ifoxhz.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n=======\n# raft-nginx\nraft-nginx 是利用hashicorp的raft 协议，实现一个边缘计算nginx网关的集群框架.\nLeader nginx支持边缘节点的读写操作，Follower节点的仅支持读操作\n里面内置了一个hraftd类似的kv-store演示相关功能，但是重新组织了代码结构，可以通过自己的FSM 实现来完成新的后端服务接入，比如一个rocksdb.\n\n待完善的点：\n1.  实现完整的snapshot功能，算法：记录最后的apply id 和term, 在新的replacited logs过来的时候，需要校验是否已经applied 的logs\n2.  核心的问题是在有状态的数据关联关系里面，实现snapshot 不被logs重放问题所困扰，是关键所在；并且同时要保持不被新的leader replicated 所覆盖或者重写\n\n\n参考了[hraftd](https://github.com/otoolep/hraftd)\n\n_For background on this project check out this [blog post](http://www.philipotoole.com/building-a-distributed-key-value-store-using-raft/)._\n\n_You should also check out the GopherCon2023 talk \"Build Your Own Distributed System Using Go\" ([video](https://www.youtube.com/watch?v=8XbxQ1Epi5w), [slides](https://www.philipotoole.com/gophercon2023)), which explains step-by-step how to use the Hashicorp Raft library._\n\n\n\n## Reading and writing keys\nThe reference implementation is a very simple in-memory key-value store. You can set a key by sending a request to the HTTP bind address (which defaults to `localhost:11000`):\n```bash\ncurl -XPOST localhost:8100/key -d '{\"foo\": \"bar\"}'\n```\n\nYou can read the value for a key like so:\n```bash\ncurl -XGET localhost:8100/key/foo\n```\n\n## Running raft-nginx\n*Building hraftd requires Go 1.20 or later.*\n\nStarting and running a hraftd cluster is easy. Download and build hraftd like so:\n```bash\nmkdir work # or any directory you like\ncd work\nexport GOPATH=$PWD\ngit clone git@github.com:ifoxhz/raft-nginx.git\ncd raft-nginx\ngo install\n```\n\nRun your first hraftd node like so:\n```bash\ndocker build -t raft-nginx:1.0.0 .\ndocker-compose up -d\n```\n\nYou can now set a key and read its value back:\n```bash\ncurl -XPOST localhost:8100/key -d '{\"user1\": \"batman\"}'\ncurl -XGET localhost:8100/key/user1\n```\n\n### Follower node\nThis tells each new node to join the existing node. Once joined, each node now knows about the key:\n```bash\ncurl -XGET localhost:8200/key/user1\ncurl -XGET localhost:8300/key/user1\n```\n\nFurthermore you can add a second key:\n```bash\ncurl -XPOST localhost:8100/key -d '{\"user2\": \"robin\"}'\n```\n\nConfirm that the new key has been set like so:\n```bash\ncurl -XGET localhost:8100/key/user2\ncurl -XGET localhost:8200/key/user2\ncurl -XGET localhost:8300/key/user2\n```\n\n### Leader-forwarding\n可以通过nginx的原生能力，转发request到Leader节点，现在的nginx没做配置\n\n## Production use of Raft\n学习是能获取更多的关键点 [rqlite](https://github.com/rqlite/rqlite).\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fifoxhz%2Fraft-nginx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fifoxhz%2Fraft-nginx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fifoxhz%2Fraft-nginx/lists"}