Package snapshot
Overview ▹
Index ▹
func Restore ¶
func Restore(logger *log.Logger, in io.Reader, r *raft.Raft) error
Restore takes the snapshot from the reader and attempts to apply it to the given Raft instance.
func Verify ¶
func Verify(in io.Reader) (*raft.SnapshotMeta, error)
Verify takes the snapshot from the reader and verifies its contents.
type Snapshot ¶
Snapshot is a structure that holds state about a temporary file that is used to hold a snapshot. By using an intermediate file we avoid holding everything in memory.
type Snapshot struct {
// contains filtered or unexported fields
}
func New ¶
func New(logger *log.Logger, r *raft.Raft) (*Snapshot, error)
New takes a state snapshot of the given Raft instance into a temporary file and returns an object that gives access to the file as an io.Reader. You must arrange to call Close() on the returned object or else you will leak a temporary file.
func (*Snapshot) Close ¶
func (s *Snapshot) Close() error
Close closes the snapshot and removes any temporary storage associated with it. You must arrange to call this whenever NewSnapshot() has been called successfully. This is safe to call on a nil snapshot.
func (*Snapshot) Index ¶
func (s *Snapshot) Index() uint64
Index returns the index of the snapshot. This is safe to call on a nil snapshot, it will just return 0.
func (*Snapshot) Read ¶
func (s *Snapshot) Read(p []byte) (n int, err error)
Read passes through to the underlying snapshot file. This is safe to call on a nil snapshot, it will just return an EOF.