Documentation ¶
Overview ¶
Package snap stores raft nodes' states with snapshots.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Read ¶
raftpb.Snapshot:
message SnapshotMetadata { optional ConfState conf_state = 1 [(gogoproto.nullable) = false]; optional uint64 index = 2 [(gogoproto.nullable) = false]; optional uint64 term = 3 [(gogoproto.nullable) = false]; }
message Snapshot { optional bytes data = 1; optional SnapshotMetadata metadata = 2 [(gogoproto.nullable) = false]; }
Types ¶
type Message ¶
type Message struct { raftpb.Message ReadCloser io.ReadCloser TotalSize int64 // contains filtered or unexported fields }
Message is a struct that contains a raft Message and a ReadCloser. The type of raft message MUST be MsgSnap, which contains the raft meta-data and an additional data []byte field that contains the snapshot of the actual state machine. Message contains the ReadCloser field for handling large snapshot. This avoid copying the entire snapshot into a byte array, which consumes a lot of memory.
User of Message should close the Message after sending it.
func NewMessage ¶
func (Message) CloseNotify ¶
CloseNotify returns a channel that receives a single value when the message sent is finished. true indicates the sent is successful.
func (Message) CloseWithError ¶
type Snapshotter ¶
type Snapshotter struct {
// contains filtered or unexported fields
}
func New ¶
func New(dir string) *Snapshotter
func (*Snapshotter) DBFilePath ¶
func (s *Snapshotter) DBFilePath(id uint64) (string, error)
DBFilePath returns the file path for the snapshot of the database with given id. If the snapshot does not exist, it returns error.
func (*Snapshotter) Load ¶
func (s *Snapshotter) Load() (*raftpb.Snapshot, error)
加载目录下的所有快照文件,返回最近的快照数据
func (*Snapshotter) SaveDBFrom ¶
SaveDBFrom saves snapshot of the database from the given reader. It guarantees the save operation is atomic.