{"id":21327517,"url":"https://github.com/jille/raft-grpc-example","last_synced_at":"2025-07-23T09:05:10.086Z","repository":{"id":41057215,"uuid":"293819299","full_name":"Jille/raft-grpc-example","owner":"Jille","description":"Example code for how to get hashicorp/raft running with gRPC","archived":false,"fork":false,"pushed_at":"2024-07-22T11:29:31.000Z","size":75,"stargazers_count":223,"open_issues_count":0,"forks_count":45,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-07-01T18:10:04.550Z","etag":null,"topics":["golang","grpc","grpc-go","hashicorp-raft","raft"],"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/Jille.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":"2020-09-08T13:30:20.000Z","updated_at":"2025-06-19T01:40:45.000Z","dependencies_parsed_at":"2024-06-18T22:35:23.231Z","dependency_job_id":"1b90c38d-347c-47a5-bcc4-be873cd74c38","html_url":"https://github.com/Jille/raft-grpc-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/Jille/raft-grpc-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jille%2Fraft-grpc-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jille%2Fraft-grpc-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jille%2Fraft-grpc-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jille%2Fraft-grpc-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jille","download_url":"https://codeload.github.com/Jille/raft-grpc-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jille%2Fraft-grpc-example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266649141,"owners_count":23962178,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["golang","grpc","grpc-go","hashicorp-raft","raft"],"created_at":"2024-11-21T21:18:00.111Z","updated_at":"2025-07-23T09:05:10.045Z","avatar_url":"https://github.com/Jille.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# raft-grpc-example\n\nThis is some example code for how to use [Hashicorp's Raft implementation](https://github.com/hashicorp/raft) with gRPC.\n\n## Start your own cluster\n\n```shell\n$ mkdir /tmp/my-raft-cluster\n$ mkdir /tmp/my-raft-cluster/node{A,B,C}\n$ ./raft-grpc-example --raft_bootstrap --raft_id=nodeA --address=localhost:50051 --raft_data_dir /tmp/my-raft-cluster\n$ ./raft-grpc-example --raft_id=nodeB --address=localhost:50052 --raft_data_dir /tmp/my-raft-cluster\n$ ./raft-grpc-example --raft_id=nodeC --address=localhost:50053 --raft_data_dir /tmp/my-raft-cluster\n$ go install github.com/Jille/raftadmin/cmd/raftadmin@latest\n$ raftadmin localhost:50051 add_voter nodeB localhost:50052 0\n$ raftadmin --leader multi:///localhost:50051,localhost:50052 add_voter nodeC localhost:50053 0\n$ go run cmd/hammer/hammer.go \u0026\n$ raftadmin --leader multi:///localhost:50051,localhost:50052,localhost:50053 leadership_transfer\n$ wait\n```\n\nYou start up three nodes, and bootstrap one of them. Then you tell the bootstrapped node where to find peers. Those peers sync up to the state of the bootstrapped node and become members of the cluster. Once your cluster is running, you never need to pass `--raft_bootstrap` again.\n\n[raftadmin](https://github.com/Jille/raftadmin) is used to communicate with the cluster and add the other nodes.\n\nThis example uses [Jille/raft-grpc-transport](https://github.com/Jille/raft-grpc-transport) to communicate between nodes using gRPC.\n\nThis example uses [Jille/raft-grpc-leader-rpc](https://github.com/Jille/raft-grpc-leader-rpc) to send RPCs to the leader.\n\nHammer is a client that connects to your raft cluster and sends a bunch of requests. Trigger some leadership failovers to show that it's unaffected.\n\n## What's what\n\nRaft uses logs to synchronize changes. Every change submitted to a Raft cluster is a log entry, which gets stored and replicated to the followers in the cluster. In this example, we use [raft-boltdb](https://github.com/hashicorp/raft-boltdb) to store these logs.\nOnce in a while Raft decides the logs have grown too large, and makes a snapshot. Your code is asked to write out its state. That state captures all previous logs. Now Raft can delete all the old logs and just use the snapshot. These snapshots are stored using the FileSnapshotStore, which means they'll just be files in your disk.\nRaft also needs a way to talk to other nodes, that's called a Transport. This example uses [Jille/raft-grpc-transport](https://github.com/Jille/raft-grpc-transport) to communicate between nodes using gRPC.\n\nYou can see all this happening in `NewRaft()` in `main.go`.\n\n## Your application\n\nSee `application.go`. You'll need to implement a `raft.FSM`, and you probably want a gRPC RPC interface.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjille%2Fraft-grpc-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjille%2Fraft-grpc-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjille%2Fraft-grpc-example/lists"}