hashicorp /raft

Golang implementation of the Raft consensus protocol

★ 9,169⑂ 1,105👁 384⑃ 452● 289▤ 27
GoMPL-2.0Created 2013-11-05
下载:v1.8.0v1.8.0 ↓1.8.02026-09-16
+3
日增长
9,169
stars
1,105
forks
384
watchers
452
prs
289
issues
27
releases

README

raft 







====

raft is a Go library that manages a replicated
log and can be used with an FSM to manage replicated state machines. It
is a library for providing consensus).

The use cases for such a library are far-reaching, such as replicated state
machines which are a key component of many distributed systems. They enable
building Consistent, Partition Tolerant (CP) systems, with limited
fault tolerance as well.

 Building

If you wish to build raft you'll need Go version 1.16+ installed.

Please check your installation with:


go version


 Documentation

For complete documentation, see the associated Godoc.

To prevent complications with cgo, the primary backend MDBStore is in a separate repository,
called raft-mdb. That is the recommended implementation
for the LogStore and StableStore.

A pure Go backend using Bbolt is also available called
raft-boltdb. It can also be used as a LogStore
and StableStore.


 Community Contributed Examples 
- Raft gRPC Example - Utilizing the Raft repository with gRPC
- Raft-based KV-store Example - Uses Hashicorp Raft to build a distributed key-value store


 Tagged Releases

As of September 2017, HashiCorp will start using tags for this library to clearly indicate
major version updates. We recommend you vendor your application's dependency on this library.

 v0.1.0 is the original stable version of the library that was in main and has been maintained
with no breaking API changes. This was in use by Consul prior to version 0.7.0.

 v1.0.0 takes the changes that were staged in the library-v2-stage-one branch. This version
manages server identities using a UUID, so introduces some breaking API changes. It also versions
the Raft protocol, and requires some special steps when interoperating with Raft servers running
older versions of the library (see the detailed comment in config.go about version compatibility).
You can reference https://github.com/hashicorp/consul/pull/2222 for an idea of what was required
to port Consul to these new interfaces.

    This version includes some new features as well, including non voting servers, a new address
    provider abstraction in the transport layer, and more resilient snapshots.

 Protocol

raft is based on "Raft: In Search of an Understandable Consensus Algorithm"

A high level overview of the Raft protocol is described below, but for details please read the full
Raft paper
followed by the raft source. Any questions about the raft protocol should be sent to the
raft-dev mailing list.

 Protocol Description

Raft nodes are always in one of three states: follower, candidate or leader. All
nodes initially start out as a follower. In this state, nodes can accept log entries
from a leader and cast votes. If no entries are received for some time, nodes
self-promote to the candidate state. In the candidate state nodes request votes from
their peers. If a candidate receives a quorum of votes, then it is promoted to a leader.
The leader must accept new log entries and replic

Top issues

Latest release

v1.8.0 v1.8.0 2026-09-16
What's Changed

 This release removes the long-standing compatibiltiy shim between hashicorp/go-metrics and armon/go-metrics. You no longer need to set build tags when consuming this library. If you have other libraries that consume this library, you should upgrade them at the same time as your application.
 Raft now persists the commit index in the LogStore to accelerate recovery

Full Changelog: https://github.com/hashicorp/raft/compare/v1.7.3...v1.8.0

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON