snap

package
v0.0.0-...-16b87a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSnapshot    = errors.New("snap: no available snapshot")
	ErrEmptySnapshot = errors.New("snap: empty snapshot")
	ErrCRCMismatch   = errors.New("snap: crc mismatch")
)
View Source
var ErrNoDBSnapshot = errors.New("snap: snapshot file doesn't exist")

Functions

func Read

func Read(lg *zap.Logger, snapname string) (*snappb.ShotData, error)

Read reads the snapshot named by snapname and returns the snapshot.

Types

type SnapshotAPI

type SnapshotAPI interface {
	// Load returns the newest snapshot.
	Load() (*snappb.ShotData, error)
	// LoadNewestAvailable loads the newest snapshot available that is in walSnaps.
	LoadNewestAvailable(walSnaps []log.Snapshot) (*snappb.ShotData, error)
	SaveSnapData(snapshot snappb.ShotData) error
	ReleaseSnapDBs(snap snappb.ShotData) error
	// SnapNames returns the filename of the snapshots in logical time order (from newest to oldest).
	// If there is no available snapshots, an ErrNoSnapshot will be returned.
	SnapNames() ([]string, error)
}

type Snapshotter

type Snapshotter struct {
	// contains filtered or unexported fields
}

func New

func New(lg *zap.Logger, 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() (*snappb.ShotData, error)

Load returns the newest snapshot.

func (*Snapshotter) LoadNewestAvailable

func (s *Snapshotter) LoadNewestAvailable(walSnaps []log.Snapshot) (*snappb.ShotData, error)

LoadNewestAvailable loads the newest snapshot available that is in walSnaps.

func (*Snapshotter) ReleaseSnapDBs

func (s *Snapshotter) ReleaseSnapDBs(snap snappb.ShotData) error

func (*Snapshotter) SaveDBFrom

func (s *Snapshotter) SaveDBFrom(r io.Reader, id uint64) (int64, error)

SaveDBFrom saves snapshot of the database from the given reader. It guarantees the save operation is atomic.

func (*Snapshotter) SaveSnapData

func (s *Snapshotter) SaveSnapData(snapshot snappb.ShotData) error

func (*Snapshotter) SnapNames

func (s *Snapshotter) SnapNames() ([]string, error)

SnapNames returns the filename of the snapshots in logical time order (from newest to oldest). If there is no available snapshots, an ErrNoSnapshot will be returned.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL