Documentation
¶
Overview ¶
Package raft implements the Raft distributed consensus protocol.
Index ¶
- Constants
- Variables
- func Address(host string, port int) string
- type AddMemberRequest
- type AddMemberResponse
- type AppendEntriesRequest
- type AppendEntriesResponse
- type BYTESCodec
- type CODECodec
- type Code
- type Codec
- type Command
- type ConfigurationStorage
- type DefaultCommand
- func (c *DefaultCommand) Do(context interface{}) (interface{}, error)
- func (d *DefaultCommand) Marshal() ([]byte, error)
- func (d *DefaultCommand) MarshalTo(buf []byte) (int, error)
- func (d *DefaultCommand) Size() int
- func (c *DefaultCommand) Type() uint64
- func (d *DefaultCommand) Unmarshal(data []byte) error
- type Entry
- type GOGOPBCodec
- type GetLeaderRequest
- type GetLeaderResponse
- type GetMetaRequest
- type GetMetaResponse
- type GoGoProtobuf
- type InstallSnapshotRequest
- type InstallSnapshotResponse
- type JSONCodec
- type LogLevel
- type MSGPCodec
- type Member
- type MsgPack
- type Node
- type RPCs
- type RemoveMemberRequest
- type RemoveMemberResponse
- type RequestVoteRequest
- type RequestVoteResponse
- type Service
- type SetMetaRequest
- type SetMetaResponse
- type Snapshot
- type SnapshotPolicy
- type SyncType
- type WAL
- type XMLCodec
Constants ¶
const ( //AllLogLevel defines the lowest level. AllLogLevel = LogLevel(log.AllLevel) //TraceLogLevel defines the level of trace in test environments. TraceLogLevel = LogLevel(log.TraceLevel) //DebugLogLevel defines the level of debug. DebugLogLevel = LogLevel(log.DebugLevel) //InfoLogLevel defines the level of info. InfoLogLevel = LogLevel(log.InfoLevel) //NoticeLogLevel defines the level of notice. NoticeLogLevel = LogLevel(log.NoticeLevel) //WarnLogLevel defines the level of warn. WarnLogLevel = LogLevel(log.WarnLevel) //ErrorLogLevel defines the level of error. ErrorLogLevel = LogLevel(log.ErrorLevel) //PanicLogLevel defines the level of panic. PanicLogLevel = LogLevel(log.PanicLevel) //FatalLogLevel defines the level of fatal. FatalLogLevel = LogLevel(log.FatalLevel) //OffLogLevel defines the level of no log. OffLogLevel = LogLevel(log.OffLevel) )
Variables ¶
var ( // ErrNotLeader is returned when this node is not Leader. ErrNotLeader = errors.New("this node is not Leader") // ErrNotRunning is returned when this node do not running. ErrNotRunning = errors.New("this node do not running") // ErrLeaderIsNotReady is returned when the leader is not ready. ErrLeaderIsNotReady = errors.New("Leader is not ready") // ErrAppendEntriesFailed is returned when append entries failed. ErrAppendEntriesFailed = errors.New("AppendEntries failed") // ErrAppendEntriesTimeout is returned when append entries timeout. ErrAppendEntriesTimeout = errors.New("AppendEntries timeout") // ErrCommandNil is returned when the command is nil. ErrCommandNil = errors.New("Command can not be nil") // ErrCommandTimeout is returned when exec the command timeout. ErrCommandTimeout = errors.New("command timeout") // ErrCommandNotRegistered is returned when the command is not registered. ErrCommandNotRegistered = errors.New("Command is not registered") // ErrCommandTypeExisted is returned when the command type is existed. ErrCommandTypeExisted = errors.New("CommandType is existed") // ErrCommandType is returned when the command type = 0. ErrCommandType = errors.New("CommandType must be > 0") // ErrSnapshotCodecNil is returned when the snapshotCodec is nil. ErrSnapshotCodecNil = errors.New("SnapshotCodec can not be nil") )
var ErrorCODE = errors.New("is not Code")
ErrorCODE is the error that v is not Code
var ErrorGOGOPB = errors.New("is not GoGoProtobuf")
ErrorGOGOPB is the error that v is not GoGoProtobuf
var ErrorMSGP = errors.New("is not MSGP")
ErrorMSGP is the error that v is not MSGP
Functions ¶
Types ¶
type AddMemberRequest ¶
type AddMemberRequest struct {
Member *Member
}
AddMemberRequest represents a rpc request of adding peer.
func (*AddMemberRequest) Marshal ¶
func (d *AddMemberRequest) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*AddMemberRequest) MarshalTo ¶
func (d *AddMemberRequest) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*AddMemberRequest) Size ¶
func (d *AddMemberRequest) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*AddMemberRequest) Unmarshal ¶
func (d *AddMemberRequest) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type AddMemberResponse ¶
AddMemberResponse represents a rpc response of adding peer.
func (*AddMemberResponse) Marshal ¶
func (d *AddMemberResponse) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*AddMemberResponse) MarshalTo ¶
func (d *AddMemberResponse) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*AddMemberResponse) Size ¶
func (d *AddMemberResponse) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*AddMemberResponse) Unmarshal ¶
func (d *AddMemberResponse) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type AppendEntriesRequest ¶
type AppendEntriesRequest struct {
Term uint64
LeaderID string
PrevLogIndex uint64
PrevLogTerm uint64
LeaderCommit uint64
Entries []*Entry
}
AppendEntriesRequest represents a rpc request of appending entries.
func (*AppendEntriesRequest) Marshal ¶
func (d *AppendEntriesRequest) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*AppendEntriesRequest) MarshalTo ¶
func (d *AppendEntriesRequest) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*AppendEntriesRequest) Size ¶
func (d *AppendEntriesRequest) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*AppendEntriesRequest) Unmarshal ¶
func (d *AppendEntriesRequest) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type AppendEntriesResponse ¶
AppendEntriesResponse represents a rpc response of appending entries.
func (*AppendEntriesResponse) Marshal ¶
func (d *AppendEntriesResponse) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*AppendEntriesResponse) MarshalTo ¶
func (d *AppendEntriesResponse) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*AppendEntriesResponse) Size ¶
func (d *AppendEntriesResponse) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*AppendEntriesResponse) Unmarshal ¶
func (d *AppendEntriesResponse) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type BYTESCodec ¶
type BYTESCodec struct {
}
BYTESCodec struct
func (*BYTESCodec) Marshal ¶
func (c *BYTESCodec) Marshal(buf []byte, v interface{}) ([]byte, error)
Marshal returns the BYTES encoding of v.
func (*BYTESCodec) Unmarshal ¶
func (c *BYTESCodec) Unmarshal(data []byte, v interface{}) error
Unmarshal parses the BYTES-encoded data and stores the result in the value pointed to by v.
type CODECodec ¶
type CODECodec struct {
}
CODECodec struct
type Codec ¶
type Codec interface {
Marshal(buf []byte, v interface{}) ([]byte, error)
Unmarshal(data []byte, v interface{}) error
}
Codec defines the interface for encoding/decoding.
type Command ¶
type Command interface {
// Type returns the command type. The type must be > 0.
Type() uint64
// Do executes the command with the context.
Do(context interface{}) (reply interface{}, err error)
}
Command represents a command.
type ConfigurationStorage ¶
type ConfigurationStorage struct {
Members []*Member
}
ConfigurationStorage represents a configuration storage.
func (*ConfigurationStorage) Marshal ¶
func (d *ConfigurationStorage) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*ConfigurationStorage) MarshalTo ¶
func (d *ConfigurationStorage) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*ConfigurationStorage) Size ¶
func (d *ConfigurationStorage) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*ConfigurationStorage) Unmarshal ¶
func (d *ConfigurationStorage) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type DefaultCommand ¶
DefaultCommand represents a operation command.
func (*DefaultCommand) Do ¶
func (c *DefaultCommand) Do(context interface{}) (interface{}, error)
Do implements the Command Do method.
func (*DefaultCommand) Marshal ¶
func (d *DefaultCommand) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*DefaultCommand) MarshalTo ¶
func (d *DefaultCommand) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*DefaultCommand) Size ¶
func (d *DefaultCommand) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*DefaultCommand) Type ¶
func (c *DefaultCommand) Type() uint64
Type implements the Command Type method.
func (*DefaultCommand) Unmarshal ¶
func (d *DefaultCommand) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type Entry ¶
Entry represents a log entry.
type GOGOPBCodec ¶
type GOGOPBCodec struct {
}
GOGOPBCodec struct
func (*GOGOPBCodec) Marshal ¶
func (c *GOGOPBCodec) Marshal(buf []byte, v interface{}) ([]byte, error)
Marshal returns the GOGOPB encoding of v.
func (*GOGOPBCodec) Unmarshal ¶
func (c *GOGOPBCodec) Unmarshal(data []byte, v interface{}) error
Unmarshal parses the GOGOPB-encoded data and stores the result in the value pointed to by v.
type GetLeaderRequest ¶
type GetLeaderRequest struct {
}
GetLeaderRequest represents a rpc request of getting leader.
func (*GetLeaderRequest) Marshal ¶
func (d *GetLeaderRequest) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*GetLeaderRequest) MarshalTo ¶
func (d *GetLeaderRequest) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*GetLeaderRequest) Size ¶
func (d *GetLeaderRequest) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*GetLeaderRequest) Unmarshal ¶
func (d *GetLeaderRequest) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type GetLeaderResponse ¶
GetLeaderResponse represents a rpc response of getting leader.
func (*GetLeaderResponse) Marshal ¶
func (d *GetLeaderResponse) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*GetLeaderResponse) MarshalTo ¶
func (d *GetLeaderResponse) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*GetLeaderResponse) Size ¶
func (d *GetLeaderResponse) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*GetLeaderResponse) Unmarshal ¶
func (d *GetLeaderResponse) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type GetMetaRequest ¶
type GetMetaRequest struct {
}
GetMetaRequest represents a rpc request of getting meta.
func (*GetMetaRequest) Marshal ¶
func (d *GetMetaRequest) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*GetMetaRequest) MarshalTo ¶
func (d *GetMetaRequest) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*GetMetaRequest) Size ¶
func (d *GetMetaRequest) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*GetMetaRequest) Unmarshal ¶
func (d *GetMetaRequest) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type GetMetaResponse ¶
type GetMetaResponse struct {
Meta []byte
}
GetMetaResponse represents a rpc response of getting meta.
func (*GetMetaResponse) Marshal ¶
func (d *GetMetaResponse) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*GetMetaResponse) MarshalTo ¶
func (d *GetMetaResponse) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*GetMetaResponse) Size ¶
func (d *GetMetaResponse) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*GetMetaResponse) Unmarshal ¶
func (d *GetMetaResponse) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type GoGoProtobuf ¶
type GoGoProtobuf interface {
Size() (n int)
Marshal() (data []byte, err error)
MarshalTo(buf []byte) (int, error)
Unmarshal(data []byte) error
}
GoGoProtobuf defines the interface for gogo's protobuf.
type InstallSnapshotRequest ¶
type InstallSnapshotRequest struct {
Term uint64
LeaderID string
LastIncludedIndex uint64
LastIncludedTerm uint64
Offset uint64
Done bool
Data []byte
}
InstallSnapshotRequest represents a rpc request of installing snapshot.
func (*InstallSnapshotRequest) Marshal ¶
func (d *InstallSnapshotRequest) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*InstallSnapshotRequest) MarshalTo ¶
func (d *InstallSnapshotRequest) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*InstallSnapshotRequest) Size ¶
func (d *InstallSnapshotRequest) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*InstallSnapshotRequest) Unmarshal ¶
func (d *InstallSnapshotRequest) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type InstallSnapshotResponse ¶
InstallSnapshotResponse represents a rpc response of installing snapshot.
func (*InstallSnapshotResponse) Marshal ¶
func (d *InstallSnapshotResponse) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*InstallSnapshotResponse) MarshalTo ¶
func (d *InstallSnapshotResponse) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*InstallSnapshotResponse) Size ¶
func (d *InstallSnapshotResponse) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*InstallSnapshotResponse) Unmarshal ¶
func (d *InstallSnapshotResponse) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type JSONCodec ¶
type JSONCodec struct {
}
JSONCodec struct
type MSGPCodec ¶
type MSGPCodec struct {
}
MSGPCodec struct
type Member ¶
Member represents a node info.
type MsgPack ¶
type MsgPack interface {
MarshalMsg(buf []byte) ([]byte, error)
UnmarshalMsg(bts []byte) (o []byte, err error)
}
MsgPack defines the interface for msgp.
type Node ¶
type Node interface {
Start()
Stop()
State() string
Leader() string
IsLeader() bool
Address() string
SetNodeMeta(address string, meta []byte) bool
GetNodeMeta(address string) ([]byte, bool)
Ready() bool
SetLogLevel(level LogLevel)
GetLogLevel() LogLevel
SetCodec(codec Codec)
SetContext(context interface{})
SetGzipSnapshot(gzip bool)
SetSnapshotPolicy(snapshotPolicy SnapshotPolicy)
SetSnapshot(snapshot Snapshot)
SetSyncTypes(saves []*SyncType)
RegisterCommand(command Command) error
Do(command Command) (interface{}, error)
ReadIndex() bool
LeaseRead() bool
Peers() []string
Join(member *Member) (success bool)
Leave(Address string) (success bool)
Members() []*Member
LeaderChange(leaderChange func())
}
Node is a raft node.
type RPCs ¶
type RPCs interface {
Register(s Service) error
ListenAndServe() error
Close() error
Ping(addr string) error
RequestVote(ctx context.Context, addr string, req *RequestVoteRequest, res *RequestVoteResponse) error
AppendEntries(ctx context.Context, addr string, req *AppendEntriesRequest, res *AppendEntriesResponse) error
InstallSnapshot(ctx context.Context, addr string, req *InstallSnapshotRequest, res *InstallSnapshotResponse) error
GetLeader(ctx context.Context, addr string, req *GetLeaderRequest, res *GetLeaderResponse) error
AddMember(ctx context.Context, addr string, req *AddMemberRequest, res *AddMemberResponse) error
RemoveMember(ctx context.Context, addr string, req *RemoveMemberRequest, res *RemoveMemberResponse) error
SetMeta(ctx context.Context, addr string, req *SetMetaRequest, res *SetMetaResponse) error
GetMeta(ctx context.Context, addr string, req *GetMetaRequest, res *GetMetaResponse) error
}
RPCs represents the RPCs.
type RemoveMemberRequest ¶
type RemoveMemberRequest struct {
Address string
}
RemoveMemberRequest represents a rpc request of removing peer.
func (*RemoveMemberRequest) Marshal ¶
func (d *RemoveMemberRequest) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*RemoveMemberRequest) MarshalTo ¶
func (d *RemoveMemberRequest) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*RemoveMemberRequest) Size ¶
func (d *RemoveMemberRequest) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*RemoveMemberRequest) Unmarshal ¶
func (d *RemoveMemberRequest) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type RemoveMemberResponse ¶
RemoveMemberResponse represents a rpc response of removing peer.
func (*RemoveMemberResponse) Marshal ¶
func (d *RemoveMemberResponse) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*RemoveMemberResponse) MarshalTo ¶
func (d *RemoveMemberResponse) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*RemoveMemberResponse) Size ¶
func (d *RemoveMemberResponse) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*RemoveMemberResponse) Unmarshal ¶
func (d *RemoveMemberResponse) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type RequestVoteRequest ¶
type RequestVoteRequest struct {
Term uint64
CandidateID string
LastLogIndex uint64
LastLogTerm uint64
}
RequestVoteRequest represents a rpc request of requesting vote.
func (*RequestVoteRequest) Marshal ¶
func (d *RequestVoteRequest) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*RequestVoteRequest) MarshalTo ¶
func (d *RequestVoteRequest) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*RequestVoteRequest) Size ¶
func (d *RequestVoteRequest) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*RequestVoteRequest) Unmarshal ¶
func (d *RequestVoteRequest) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type RequestVoteResponse ¶
RequestVoteResponse represents a rpc response of requesting vote.
func (*RequestVoteResponse) Marshal ¶
func (d *RequestVoteResponse) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*RequestVoteResponse) MarshalTo ¶
func (d *RequestVoteResponse) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*RequestVoteResponse) Size ¶
func (d *RequestVoteResponse) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*RequestVoteResponse) Unmarshal ¶
func (d *RequestVoteResponse) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type Service ¶
type Service interface {
RequestVote(req *RequestVoteRequest, res *RequestVoteResponse) error
AppendEntries(req *AppendEntriesRequest, res *AppendEntriesResponse) error
InstallSnapshot(req *InstallSnapshotRequest, res *InstallSnapshotResponse) error
GetLeader(req *GetLeaderRequest, res *GetLeaderResponse) error
AddMember(req *AddMemberRequest, res *AddMemberResponse) error
RemoveMember(req *RemoveMemberRequest, res *RemoveMemberResponse) error
SetMeta(req *SetMetaRequest, res *SetMetaResponse) error
GetMeta(req *GetMetaRequest, res *GetMetaResponse) error
}
Service represents the RPCs service.
type SetMetaRequest ¶
type SetMetaRequest struct {
Meta []byte
}
SetMetaRequest represents a rpc request of setting meta.
func (*SetMetaRequest) Marshal ¶
func (d *SetMetaRequest) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*SetMetaRequest) MarshalTo ¶
func (d *SetMetaRequest) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*SetMetaRequest) Size ¶
func (d *SetMetaRequest) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*SetMetaRequest) Unmarshal ¶
func (d *SetMetaRequest) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type SetMetaResponse ¶
type SetMetaResponse struct {
Success bool
}
SetMetaResponse represents a rpc response of setting meta.
func (*SetMetaResponse) Marshal ¶
func (d *SetMetaResponse) Marshal() ([]byte, error)
Marshal returns the encoded bytes.
func (*SetMetaResponse) MarshalTo ¶
func (d *SetMetaResponse) MarshalTo(buf []byte) (int, error)
MarshalTo marshals into buf and returns the number of bytes.
func (*SetMetaResponse) Size ¶
func (d *SetMetaResponse) Size() int
Size returns the size of the buffer required to represent the data when encoded.
func (*SetMetaResponse) Unmarshal ¶
func (d *SetMetaResponse) Unmarshal(data []byte) error
Unmarshal unmarshals from data.
type Snapshot ¶
type Snapshot interface {
// Save writes snapshot data to w until there's no more data to write or
// when an error occurs. The return value n is the number of bytes
// written. Any error encountered during the write is also returned.
Save(w io.Writer) (n int, err error)
// Recover reads snapshot data from r until EOF or error.
// The return value n is the number of bytes read.
// Any error except io.EOF encountered during the read is also returned.
Recover(r io.Reader) (n int, err error)
}
Snapshot saves a snapshot and recovers from a snapshot.
type SnapshotPolicy ¶
type SnapshotPolicy int
SnapshotPolicy represents a snapshot policy type.
const ( // Never is a SnapshotPolicy that will never sync the snapshot to the disk. Never SnapshotPolicy = 0 // EverySecond is a SnapshotPolicy that will sync the snapshot to the disk every second. EverySecond SnapshotPolicy = 1 // EveryMinute is a SnapshotPolicy that will sync the snapshot to the disk every minute. EveryMinute SnapshotPolicy = 2 // EveryHour is a SnapshotPolicy that will sync the snapshot to the disk every hour. EveryHour SnapshotPolicy = 3 // EveryDay is a SnapshotPolicy that will sync the snapshot to the disk every day. EveryDay SnapshotPolicy = 4 // DefalutSync is a defalut SnapshotPolicy. DefalutSync SnapshotPolicy = 5 // CustomSync is a custom SnapshotPolicy. CustomSync SnapshotPolicy = 6 )
type WAL ¶
type WAL interface {
FirstIndex() (uint64, error)
LastIndex() (uint64, error)
Read(index uint64) ([]byte, error)
Write(index uint64, data []byte) error
Flush() error
Sync() error
Clean(index uint64) error
Truncate(index uint64) error
Reset() error
Close() error
}
WAL represents the write-ahead log.
Source Files
¶
- cache.go
- cluster.go
- codec.go
- command.go
- configuration.go
- const.go
- election.go
- errors.go
- invoker.go
- logger.go
- node.go
- peer.go
- persistent_uint64.go
- pipe.go
- raft.go
- raft.pb.go
- read_index.go
- rpcs.go
- service.go
- snapshot.go
- snapshot_sync.go
- state.go
- state_candidate.go
- state_follower.go
- state_leader.go
- state_machine.go
- storage.go
- util.go
- vote.go
- wal.go



