snapshot

package
v0.3.0-pre9 Latest Latest
Warning

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

Go to latest
Published: May 31, 2019 License: Apache-2.0 Imports: 15 Imported by: 9

Documentation

Overview

Package snapshot manages metadata about snapshots stored in repository.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GroupBySource

func GroupBySource(manifests []*Manifest) [][]*Manifest

GroupBySource returns a slice of slices, such that each result item contains manifests from a single source.

func ListSnapshotManifests

func ListSnapshotManifests(ctx context.Context, rep *repo.Repository, src *SourceInfo) ([]string, error)

ListSnapshotManifests returns the list of snapshot manifests for a given source or all sources if nil.

func SaveSnapshot

func SaveSnapshot(ctx context.Context, rep *repo.Repository, manifest *Manifest) (string, error)

SaveSnapshot persists given snapshot manifest and returns manifest ID.

Types

type DirEntry

type DirEntry struct {
	Name        string               `json:"name,omitempty"`
	Type        EntryType            `json:"type,omitempty"`
	Permissions Permissions          `json:"mode,omitempty"`
	FileSize    int64                `json:"size,omitempty"`
	ModTime     time.Time            `json:"mtime,omitempty"`
	UserID      uint32               `json:"uid,omitempty"`
	GroupID     uint32               `json:"gid,omitempty"`
	ObjectID    object.ID            `json:"obj,omitempty"`
	DirSummary  *fs.DirectorySummary `json:"summ,omitempty"`
}

DirEntry represents a directory entry as stored in JSON stream.

type EntryType

type EntryType string

EntryType is a type of a filesystem entry.

const (
	EntryTypeUnknown   EntryType = ""  // unknown type
	EntryTypeFile      EntryType = "f" // file
	EntryTypeDirectory EntryType = "d" // directory
	EntryTypeSymlink   EntryType = "s" // symbolic link
)

Supported entry types.

type Manifest

type Manifest struct {
	ID     string     `json:"-"`
	Source SourceInfo `json:"source"`

	Description string    `json:"description"`
	StartTime   time.Time `json:"startTime"`
	EndTime     time.Time `json:"endTime"`

	HashCacheID         object.ID `json:"hashCache"`
	HashCacheCutoffTime time.Time `json:"hashCacheCutoff"`
	Stats               Stats     `json:"stats"`
	IncompleteReason    string    `json:"incomplete,omitempty"`

	RootEntry *DirEntry `json:"rootEntry"`

	RetentionReasons []string `json:"-"`
}

Manifest represents information about a single point-in-time filesystem snapshot.

func ListSnapshots

func ListSnapshots(ctx context.Context, rep *repo.Repository, si SourceInfo) ([]*Manifest, error)

ListSnapshots lists all snapshots for a given source.

func LoadSnapshots

func LoadSnapshots(ctx context.Context, rep *repo.Repository, names []string) ([]*Manifest, error)

LoadSnapshots efficiently loads and parses a given list of snapshot IDs.

func SortByTime

func SortByTime(manifests []*Manifest, reverse bool) []*Manifest

SortByTime returns a slice of manifests sorted by start time.

func (*Manifest) RootObjectID

func (m *Manifest) RootObjectID() object.ID

RootObjectID returns the ID of a root object.

type Permissions

type Permissions int

Permissions encapsulates UNIX permissions for a filesystem entry.

func (Permissions) MarshalJSON

func (p Permissions) MarshalJSON() ([]byte, error)

MarshalJSON emits permissions as octal string.

func (*Permissions) UnmarshalJSON

func (p *Permissions) UnmarshalJSON(b []byte) error

UnmarshalJSON parses octal permissions string from JSON.

type SourceInfo

type SourceInfo struct {
	Host     string `json:"host"`
	UserName string `json:"userName"`
	Path     string `json:"path"`
}

SourceInfo represents the information about snapshot source.

func ListSources

func ListSources(ctx context.Context, rep *repo.Repository) ([]SourceInfo, error)

ListSources lists all snapshot sources in a given repository.

func ParseSourceInfo

func ParseSourceInfo(path string, hostname string, username string) (SourceInfo, error)

ParseSourceInfo parses a given path in the context of given hostname and username and returns SourceInfo. The path may be bare (in which case it's interpreted as local path and canonicalized) or may be 'username@host:path' where path, username and host are not processed.

func (SourceInfo) String

func (ssi SourceInfo) String() string

type Stats

type Stats struct {
	Block block.Stats `json:"repo,omitempty"`

	TotalDirectoryCount int   `json:"dirCount"`
	TotalFileCount      int   `json:"fileCount"`
	TotalFileSize       int64 `json:"totalSize"`

	ExcludedFileCount     int   `json:"excludedFileCount"`
	ExcludedTotalFileSize int64 `json:"excludedTotalSize"`
	ExcludedDirCount      int   `json:"excludedDirCount"`

	CachedFiles    int `json:"cachedFiles"`
	NonCachedFiles int `json:"nonCachedFiles"`

	ReadErrors int `json:"readErrors"`
}

Stats keeps track of snapshot generation statistics.

func (*Stats) AddExcluded

func (s *Stats) AddExcluded(md fs.Entry)

AddExcluded adds the information about excluded file to the statistics.

Directories

Path Synopsis
Package policy implements management of snapshot policies.
Package policy implements management of snapshot policies.
Package snapshotfs implements virtual filesystem on top of snapshots in repo.Repository.
Package snapshotfs implements virtual filesystem on top of snapshots in repo.Repository.

Jump to

Keyboard shortcuts

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