Documentation ¶
Index ¶
- Variables
- type Config
- type Engine
- type Mux
- type Operator
- func Fallback(ops ...Operator) Operator
- func ForceJoin(addr string, timeout time.Duration) Operator
- func ForceNewCluster() Operator
- func InitCluster() Operator
- func Join(addr string, timeout time.Duration) Operator
- func Members(membs ...raftpb.Member) Operator
- func Restart() Operator
- func Restore(path string) Operator
- type StateMachine
Constants ¶
This section is empty.
Variables ¶
var ( // ErrStopped is returned by the Engine methods after a call to // Shutdown or when it has not started. ErrStopped = errors.New("raft: node not ready yet or has been stopped") // ErrNoLeader is returned by the Engine methods when leader lost, or // no elected cluster leader. ErrNoLeader = errors.New("raft: no elected cluster leader") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config interface { Mux() Mux RaftConfig() *raft.Config SnapInterval() uint64 Pool() membership.Pool Storage() storage.Storage Dial() transport.Dial TickInterval() time.Duration StateMachine() StateMachine Context() context.Context DrainTimeout() time.Duration GroupID() uint64 Logger() raftlog.Logger }
Config define common configuration used by the daemon.
type Engine ¶
type Engine interface { LinearizableRead(ctx context.Context) error Push(m etcdraftpb.Message) error TransferLeadership(context.Context, uint64) error Status() (raft.Status, error) Shutdown(context.Context) error ProposeReplicate(ctx context.Context, data []byte) error ProposeConfChange(ctx context.Context, m *raftpb.Member, t etcdraftpb.ConfChangeType) error CreateSnapshot() (etcdraftpb.Snapshot, error) Start(addr string, oprs ...Operator) error ReportUnreachable(id uint64) ReportSnapshot(id uint64, status raft.SnapshotStatus) ReportShutdown(id uint64) }
Engine represents the underlying raft node processor.
type Mux ¶
type Mux interface { Start() Stop() // contains filtered or unexported methods }
Mux represents a multi node state that is participating in multiple consensus groups, a mux is more efficient than a collection of nodes. the name mux stands for "multiplexer". Like the standard "http.ServeMux".
type Operator ¶
Operator is a bootstrapper func that determine the action that is to be performed or considered.
func ForceJoin ¶
ForceJoin returns operator that sends rpc request to join an existing cluster, even if already part of a cluster.
func ForceNewCluster ¶
func ForceNewCluster() Operator
ForceNewCluster returns operator that initializes a new cluster from state dir.
func InitCluster ¶
func InitCluster() Operator
InitCluster returns operator that initializes a new cluster and create first raft node..
type StateMachine ¶
type StateMachine interface { // Apply committed raft log entry. Apply([]byte) // Snapshot is used to write the current state to a snapshot file, // on stable storage and compacting the raft logs. Snapshot() (io.ReadCloser, error) // Restore is used to restore state machine from a snapshot. Restore(io.ReadCloser) error }
StateMachine define an interface that must be implemented by application to make use of the raft replicated log.