{"id":18773892,"url":"https://github.com/ejunjsh/raftkv","last_synced_at":"2025-12-14T02:30:17.803Z","repository":{"id":109691063,"uuid":"179625429","full_name":"ejunjsh/raftkv","owner":"ejunjsh","description":"🥒 distributed key/value storage with raft","archived":false,"fork":false,"pushed_at":"2019-07-23T06:12:22.000Z","size":2604,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-29T08:41:54.878Z","etag":null,"topics":["go","key-value-store","raft"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ejunjsh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-04-05T05:42:19.000Z","updated_at":"2023-12-18T02:43:02.000Z","dependencies_parsed_at":"2023-03-13T14:05:05.170Z","dependency_job_id":null,"html_url":"https://github.com/ejunjsh/raftkv","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/ejunjsh%2Fraftkv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejunjsh%2Fraftkv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejunjsh%2Fraftkv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejunjsh%2Fraftkv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ejunjsh","download_url":"https://codeload.github.com/ejunjsh/raftkv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239680985,"owners_count":19679509,"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":["go","key-value-store","raft"],"created_at":"2024-11-07T19:36:09.500Z","updated_at":"2025-12-14T02:30:17.751Z","avatar_url":"https://github.com/ejunjsh.png","language":"Go","readme":"# raftkv\n\n[![Build Status](https://travis-ci.org/ejunjsh/raftkv.svg?branch=master)](https://travis-ci.org/ejunjsh/raftkv)\n\ndistributed key value storage with raft\n\nmost of the code is from [etcd](https://github.com/etcd-io/etcd) , just for reading and learning its source code\n\n## Getting Started\n\n### install from remote\n\n    go get github.com/ejunjsh/raftkv/cmd/raftkvd\n    \n    \n### build and test locally\n\n    cd $GOPATH/src/github.com/ejunjsh/raftkv/\n    sh ci.sh\n\n### Running single node\n\nFirst start a single-member cluster of raftkvd:\n\n```sh\nraftkvd --id 1 --cluster http://127.0.0.1:12379 --port 12380\n```\n\nEach raftkvd process maintains a single raft instance and a key-value server.\nThe process's list of comma separated peers (--cluster), its raft ID index into the peer list (--id), and http key-value server port (--port) are passed through the command line.\n\nNext, store a value (\"hello\") to a key (\"my-key\"):\n\n```\ncurl -L http://127.0.0.1:12380/my-key -XPUT -d hello\n```\n\nFinally, retrieve the stored key:\n\n```\ncurl -L http://127.0.0.1:12380/my-key\n```\n\n### Running a local cluster\n\n    raftkvd --id 1 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 12380\n    raftkvd --id 2 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 22380\n    raftkvd --id 3 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 32380\n\nThis will bring up three raftkvd instances.\n\nNow it's possible to write a key-value pair to any member of the cluster and likewise retrieve it from any member.\n\n### Fault Tolerance\n\nTo test cluster recovery, first start a cluster and write a value \"foo\":\n```sh\n# start all nodes before\nraftkvd --id 1 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 12380\nraftkvd --id 2 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 22380\nraftkvd --id 3 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 32380\n\ncurl -L http://127.0.0.1:12380/my-key -XPUT -d foo\n```\n\nNext, remove a node and replace the value with \"bar\" to check cluster availability:\n\n```sh\n# kill the node 2 before\nkill ...\ncurl -L http://127.0.0.1:12380/my-key -XPUT -d bar\ncurl -L http://127.0.0.1:32380/my-key\n```\n\nFinally, bring the node back up and verify it recovers with the updated value \"bar\":\n```sh\n# restart node 2 before\nraftkvd --id 2 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 22380\ncurl -L http://127.0.0.1:22380/my-key\n```\n\n### Dynamic cluster reconfiguration\n\nNodes can be added to or removed from a running cluster using requests to the REST API.\n\nFor example, suppose we have a 3-node cluster that was started with the commands:\n```sh\nraftkvd --id 1 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 12380\nraftkvd --id 2 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 22380\nraftkvd --id 3 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 32380\n```\n\nA fourth node with ID 4 can be added by issuing a POST:\n```sh\ncurl -L http://127.0.0.1:12380/4 -XPOST -d http://127.0.0.1:42379\n```\n\nThen the new node can be started as the others were, using the --join option:\n```sh\nraftkvd --id 4 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379,http://127.0.0.1:42379 --port 42380 --join\n```\n\nThe new node should join the cluster and be able to service key/value requests.\n\nWe can remove a node using a DELETE request:\n```sh\ncurl -L http://127.0.0.1:12380/3 -XDELETE\n```\n\nNode 3 should shut itself down once the cluster has processed this request.\n\n## reference\n\nhttps://github.com/etcd-io/etcd\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fejunjsh%2Fraftkv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fejunjsh%2Fraftkv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fejunjsh%2Fraftkv/lists"}