storage

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyAFile

func CopyAFile(source AStore, target WritableAStore, aFile AFile) error

func Sort

func Sort(dFiles []DFile)

Types

type AFile

type AFile struct {
	Prefix      string
	Hour        hour.Hour
	Hash        Hash
	Compression config.Compression
}

func ListAFilesInHour

func ListAFilesInHour(aStore AStore, hour hour.Hour) ([]AFile, error)

func NewAFileFromString

func NewAFileFromString(s string) (AFile, bool)

NewAFileFromString (re)constructs a AFile from a string representation of it; i.e., from the output of the AFile String method.

func (AFile) Equals

func (a AFile) Equals(other AFile) bool

func (AFile) LegacyString

func (a AFile) LegacyString() string

LegacyString returns a string representation of the AFile as it used to be in older versions of Hoard.

func (AFile) String

func (a AFile) String() string

String returns a string representation of the AFile. In Hoard, this string representation is always used as the AFile's file name when stored on disk.

type AStore

type AStore interface {
	WritableAStore

	ReadableAStore

	Delete(aFile AFile) error

	fmt.Stringer
}

type DFile

type DFile struct {
	Prefix  string
	Postfix string
	Time    time.Time
	Hash    Hash
}

func NewDFileFromString

func NewDFileFromString(s string) (DFile, bool)

NewDFileFromString (re)constructs a DFile from a string representation of it; i.e., from the output of the DFile String method.

func (*DFile) String

func (d *DFile) String() string

String returns a string representation of the DFile. In Hoard, this string representation is always used as the DFile's file name when stored on disk.

type DStore

type DStore interface {
	ReadableDStore
	WritableDStore

	// Lists all hours for which there is at least 1 DFile whose time is within that hour
	ListNonEmptyHours() ([]hour.Hour, error)

	ListInHour(hour hour.Hour) ([]DFile, error)

	Delete(dFile DFile) error
}

type DStoreFactory

type DStoreFactory interface {
	New() (DStore, func())
}

type Hash

type Hash string

func CalculateHash

func CalculateHash(b []byte) Hash

func ExampleHash

func ExampleHash() Hash

func ExampleHash2

func ExampleHash2() Hash

type ReadableAStore

type ReadableAStore interface {
	// TODO: audit all usages of this to ensure the reader is closed
	// TODO: ensure all implementers return nil on error
	Get(aFile AFile) (io.ReadCloser, error)

	// Searches for  all hours for which there is at least 1 AFile whose time is within that hour
	Search(startOpt *hour.Hour, end hour.Hour) ([]SearchResult, error)
}

type ReadableDStore

type ReadableDStore interface {
	// TODO: audit all usages of this to ensure the reader is closed
	// TODO: ensure all implementers return nil on error
	Get(dFile DFile) (io.ReadCloser, error)
}

type SearchResult

type SearchResult struct {
	Hour   hour.Hour
	AFiles map[AFile]bool
}

func NewAStoreSearchResult

func NewAStoreSearchResult(hour hour.Hour) SearchResult

type WritableAStore

type WritableAStore interface {
	Store(aFile AFile, content io.Reader) error
}

type WritableDStore

type WritableDStore interface {
	Store(dFile DFile, content io.Reader) error
}

Directories

Path Synopsis
Package astore contains implementations for different AStores used in Hoard
Package astore contains implementations for different AStores used in Hoard
Package dstore contains implementations for different DStores used in Hoard
Package dstore contains implementations for different DStores used in Hoard

Jump to

Keyboard shortcuts

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