Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DefaultRetainSnapshotCount is the default number of snaphots to keep. DefaultRetainSnapshotCount = 2 // DefaultRaftTimeout is the default timeout of the Raft cluster. DefaultRaftTimeout = 10 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct { // RaftDirectory is the directory where all the Raft protocol files (e.g. // the log, the snaphots, the persistent store) will be kept. RaftDirectory string // RaftBindAddress is the network address on which the Raft protocol will // be listening on. RaftBindAddress string // RaftRetainSnapshotCount is the number of Raft snaphots to keep. RaftRetainSnapshotCount int // RaftTimeout is the timeout of the Raft cluster. RaftTimeout time.Duration // NodeID is the unique ID of the server in the cluster. NodeID string // Raft is the underlying Raft consensus cluster. Raft *raft.Raft // Transport is the underlying transport layer for Raft. Transport *raft.NetworkTransport // Snapshots is the underlying snapshots store. Snapshots *raft.FileSnapshotStore }
Cluster represents a raft cluster
func New ¶
New creates a new Cluster and associates it with the given finite state machine (FSM), with the given cluster options.
type Option ¶
type Option func(cluster *Cluster)
Option represents the optional function.
func WithRaftBindAddress ¶
WithRaftBindAddress sets up the network address on which the Raft protocol endpoint will be made available.
func WithRaftDirectory ¶
WithRaftDirectory sets up the directory where Raft protocol will be kept.
func WithRaftRetainSnapshotCount ¶
WithRaftRetainSnapshotCount sets up the number of Raft snapshots to keep.
func WithRaftTimeout ¶
WithRaftTimeout sets up the timeout of the Raft cluster.
Click to show internal directories.
Click to hide internal directories.