store

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsVersionAlreadyExists

func IsVersionAlreadyExists(err error) bool

func IsVersionNotFound

func IsVersionNotFound(err error) bool

func NewVersionNotFoundError

func NewVersionNotFoundError(msg string) error

func NewVersionNotFoundErrorWithCause

func NewVersionNotFoundErrorWithCause(msg string, cause error) error

Types

type Metrics

type Metrics struct {
	Read  ReadMetrics
	Write WriteMetrics
}

type Option

type Option func(s *Store) error
var FailWhenMissingDir Option = func(s *Store) error {
	s.failWhenMissingDir = true
	return nil
}
var NoIntegrityCheck Option = func(s *Store) error {
	s.areChecksumsEqual = func(expected, actual []byte) bool {
		return true
	}
	return nil
}

type ReadMetrics

type ReadMetrics struct {
	ReaderCalls    int // Number of Store.Reader() calls
	TotalBytesRead int
	TotalTime      time.Duration
}

type Reader

type Reader interface {
	io.ReadCloser
	Version() Version
}

type ReaderOption

type ReaderOption func(*ReaderOptions) error

func Time

func Time(t time.Time) ReaderOption

type ReaderOptions

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

type Store

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

func Open

func Open(dir string, options ...Option) (*Store, error)

func (*Store) DeleteVersion

func (s *Store) DeleteVersion(t time.Time) error

func (*Store) Metrics

func (s *Store) Metrics() Metrics

func (*Store) Reader

func (s *Store) Reader(options ...ReaderOption) (Reader, error)

func (*Store) Versions

func (s *Store) Versions() ([]Version, error)

Versions return slice sorted by time, oldest first

func (*Store) Writer

func (s *Store) Writer(options ...WriterOption) (Writer, error)

type Version

type Version struct {
	// Time uniquely identifies version
	Time time.Time
	Size int64
}

type WriteMetrics

type WriteMetrics struct {
	WriterCalls       int // Number of Store.Writer() calls
	Successful        int // Number of successful writes (when writer was closed without aborting)
	Aborted           int // Number of aborted writes (when Writer.AbortAndClose was called)
	TotalBytesWritten int
	TotalTime         time.Duration
}

type Writer

type Writer interface {
	io.Writer
	// Close must be called to make version readable
	Close() error
	Version() Version
	// AbortAndClose aborts writing version. Version will not be available to read.
	AbortAndClose()
}

type WriterOption

type WriterOption func(*WriterOptions) error
var NoSync WriterOption = func(o *WriterOptions) error {
	o.sync = func(file *os.File) error {
		return nil
	}
	return nil
}

func WriteTime

func WriteTime(t time.Time) WriterOption

WriteTime is not named Time to avoid name conflict with ReaderOption

type WriterOptions

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

Jump to

Keyboard shortcuts

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