{"id":17081662,"url":"https://github.com/yongman/leto","last_synced_at":"2025-03-17T10:34:29.734Z","repository":{"id":41453455,"uuid":"141312089","full_name":"yongman/leto","owner":"yongman","description":"A key value storage example powered by hashicorp raft and BadgerDB","archived":false,"fork":false,"pushed_at":"2018-07-30T09:23:08.000Z","size":1134,"stargazers_count":103,"open_issues_count":0,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-27T22:31:37.509Z","etag":null,"topics":["hashicorp","object-storage","raft","raft-consensus-algorithm","raft-example","raft-go","raft-protocol","redis","redis-protocol"],"latest_commit_sha":null,"homepage":"https://xiking.win/leto","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/yongman.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}},"created_at":"2018-07-17T15:54:09.000Z","updated_at":"2025-02-23T20:06:00.000Z","dependencies_parsed_at":"2022-09-03T02:11:29.212Z","dependency_job_id":null,"html_url":"https://github.com/yongman/leto","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/yongman%2Fleto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yongman%2Fleto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yongman%2Fleto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yongman%2Fleto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yongman","download_url":"https://codeload.github.com/yongman/leto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243858016,"owners_count":20359261,"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":["hashicorp","object-storage","raft","raft-consensus-algorithm","raft-example","raft-go","raft-protocol","redis","redis-protocol"],"created_at":"2024-10-14T12:55:33.558Z","updated_at":"2025-03-17T10:34:29.221Z","avatar_url":"https://github.com/yongman.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Leto\n\n## 0. What is Leto mean?\n\nIn Greek mythology, [Leto](https://en.wikipedia.org/wiki/Leto) (/ˈliːtoʊ/) is a daughter of the Titans Coeus and Phoebe, the sister of Asteria.\n\n## 1. What is Leto?\n\nLeto is another reference example use of [Hashicorp Raft](https://github.com/hashicorp/raft). The API is [redis protocol](https://redis.io/topics/protocol) compatiable.\n\n[Raft](https://raft.github.io/)  is a consensus algorithm that is designed to be easy to understand. It's equivalent to Paxos in fault-tolerance and performance. The difference is that it's decomposed into relatively independent subproblems, and it cleanly addresses all major pieces needed for practical systems. We hope Raft will make consensus available to a wider audience, and that this wider audience will be able to develop a variety of higher quality consensus-based systems than are available today.\n\n## 2. Why do this?\n\nYou can have better comprehension about how `raft protocal` works if you use it. This helps me a lot.\n\n\n## 3. Run sample\n\n**3.1 show helps**\n```\nbin/leto -h\nUsage of bin/leto:\n  -id string\n        node id\n  -join string\n        join to already exist cluster\n  -listen string\n        server listen address (default \":5379\")\n  -raftbind string\n        raft bus transport bind address (default \":15379\")\n  -raftdir string\n        raft data directory (default \"./\")\n```\n\n**3.2 Start first node**\n\n```\nbin/leto -id id1 -raftdir ./id1\n```\nthe first node will be listen user request and node join request in port `5379`, and use port `15379` for raft transport.\n\n**3.3 Start second node**\n\n```\nbin/leto -id id2 -raftdir ./id2 -listen \":6379\" -raftbind \":16379\" -join \"127.0.0.1:5379\"\n```\n\n**3.4 Start third node**\n\n```\nbin/leto -id id3 -raftdir ./id3 -listen \":7379\" -raftbind \":17379\" -join \"127.0.0.1:5379\"\n```\n\n**3.5 Test**\n\nRequst first node\n```\nredis-cli -p 5379\n127.0.0.1:5379\u003e set a b\nOK\n127.0.0.1:5379\u003e get a\nb\n127.0.0.1:5379\u003e\n```\n\nWrite to second node, data has been replicated to this node. And it will return `not leader error` if write to it.\n\n```\nredis-cli -p 6379\n127.0.0.1:6379\u003e get a\nb\n127.0.0.1:6379\u003e set a b\n(error) not leader\n127.0.0.1:6379\u003e\n```\n\nNow, we  `shutdown` the first node, the second node voted to be leader.\n```\nredis-cli -p 6379\n127.0.0.1:6379\u003e get a\nb\n127.0.0.1:6379\u003e set a b\nOK\n127.0.0.1:6379\u003e\n```\n\n## 4. Support commands\n\n- GET\n- SET\n- DELETE\n- JOIN (communicate with peer when start node)\n- LEAVE (remove dead node from raft group)\n- PING\n- SNAPSHOT (trigger snapshot mannually)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyongman%2Fleto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyongman%2Fleto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyongman%2Fleto/lists"}