snapshot

package
v5.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StorageBoltDB
)

Snapshot type constants

Variables

View Source
var ErrEncMetadata = errors.New("snapshot metadata cannot be encoded")

ErrEncMetadata represents an error when encoding snapshot metadata

View Source
var ErrMetadataRead = errors.New("snapshot metadata cannot be decoded")

ErrMetadataRead represents an error when metadata cannot be decoded

View Source
var ErrMetadataSizeRead = errors.New("snapshot metadata size cannot be decoded")

ErrMetadataSizeRead represents an error when reading the metadata size

View Source
var ErrNonexistantFile = errors.New("cannot find snapshot file")

ErrNonexistantFile represents an error when the snapshot passed in to be decoded is missing

View Source
var ErrSnapshotSize = errors.New("invalid snapshot size")

ErrSnapshotSize represents an error when reading the snapshot size

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	Version uint64
	Storage uint64
}

Metadata represents the Snapshot metadata object

type Snapshot

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

Snapshot represents a snapshot struct with metadata and data

func Decode

func Decode(snap []byte) (*Snapshot, error)

Decode decode a byte slice and returns the Snapshot object

func DecodeFromFile

func DecodeFromFile(path string) (*Snapshot, error)

DecodeFromFile decodes a snapshot file from a given path

func New

func New(meta Metadata, data []byte) (*Snapshot, error)

New returns an instance of Snapshot object with the parameter set

func (*Snapshot) Data

func (s *Snapshot) Data() ([]byte, error)

Data returns the unzipped Snapshot data

func (*Snapshot) Encode

func (s *Snapshot) Encode() ([]byte, error)

Encode returns the bytes slice snapshot representation Snapshot Layout:

			         |metadata-size|metadata|data|

        metadata-size: uint64 (8 bytes) specifies the amount of metadata bytes
        metadata: Gob encoded of Metadata struct
        data: Proxy data, byte slice. The Metadata have information about it, Storage, Gzipped and version.

func (*Snapshot) Meta

func (s *Snapshot) Meta() Metadata

Meta returns a copy of the Snapshot Metadata object

func (*Snapshot) WriteDataToFile

func (s *Snapshot) WriteDataToFile(path string) error

WriteDataToFile writes the data field (unzipped) to a given file path

func (*Snapshot) WriteDataToTmpFile

func (s *Snapshot) WriteDataToTmpFile() (string, error)

WriteDataToTmpFile writes the data field (unzipped) to a temporal file

Jump to

Keyboard shortcuts

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