persistence

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiskPersistedStorage

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

func (*DiskPersistedStorage) Delete

func (b *DiskPersistedStorage) Delete(k Key) error

func (*DiskPersistedStorage) Get

func (*DiskPersistedStorage) PeriodicallyReportUsageMetrics

func (b *DiskPersistedStorage) PeriodicallyReportUsageMetrics(ctx context.Context, labels ...string)

func (*DiskPersistedStorage) Put

func (b *DiskPersistedStorage) Put(k Key, r io.Reader, t time.Time) error

func (*DiskPersistedStorage) Search

func (b *DiskPersistedStorage) Search(parent Prefix) ([]SearchResult, error)

func (*DiskPersistedStorage) String

func (b *DiskPersistedStorage) String() string

type InMemoryPersistedStorage

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

InMemoryPersistedStorage is a PersistedStorage that stores data in memory. It is, of course, an oxymoron. The type exists for testing only and as fallback for temporary storage when an on-disk temporary store cannot be obtained.

func NewInMemoryPersistedStorage

func NewInMemoryPersistedStorage() *InMemoryPersistedStorage

func (*InMemoryPersistedStorage) Delete

func (b *InMemoryPersistedStorage) Delete(k Key) error

func (*InMemoryPersistedStorage) Get

func (*InMemoryPersistedStorage) PeriodicallyReportUsageMetrics

func (b *InMemoryPersistedStorage) PeriodicallyReportUsageMetrics(ctx context.Context, labels ...string)

func (*InMemoryPersistedStorage) Put

func (*InMemoryPersistedStorage) Search

func (*InMemoryPersistedStorage) String

func (b *InMemoryPersistedStorage) String() string

type Key

type Key struct {
	Prefix Prefix
	Name   string
}

func (Key) Equals

func (k Key) Equals(k2 Key) bool

type ObjectPersistedStorage

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

func (ObjectPersistedStorage) Delete

func (s ObjectPersistedStorage) Delete(k Key) error

func (ObjectPersistedStorage) Get

func (ObjectPersistedStorage) PeriodicallyReportUsageMetrics

func (s ObjectPersistedStorage) PeriodicallyReportUsageMetrics(ctx context.Context, labels ...string)

func (ObjectPersistedStorage) Put

func (ObjectPersistedStorage) Search

Search returns a list of all prefixes such that there is at least one key in storage with that prefix.

func (ObjectPersistedStorage) String

func (s ObjectPersistedStorage) String() string

type PersistedStorage

type PersistedStorage interface {
	Put(k Key, reader io.Reader, t time.Time) error

	// TODO: audit all usages of this to ensure the reader is closed
	Get(k Key) (io.ReadCloser, error)

	// Delete deletes the bytes associated with the provided key.
	//
	// If the key does not exist in storage, nil is returned.
	Delete(k Key) error

	// Search returns a list of all prefixes such that there is at least one key in storage
	// with that prefix as a superprefix.
	Search(p Prefix) ([]SearchResult, error)

	// PeriodicallyReportUsageMetrics periodically reports Prometheus metrics
	// for the storage, until the context is cancelled.
	//
	// Each implementation can require certain labels, or ignore labels entirely.
	PeriodicallyReportUsageMetrics(ctx context.Context, labels ...string)

	fmt.Stringer
}

PersistedStorage is a place where bytes can be stored under a key.

func NewDiskPersistedStorage

func NewDiskPersistedStorage(root string) PersistedStorage

func NewObjectPersistedStorage

func NewObjectPersistedStorage(ctx context.Context, c *config.ObjectStorage, f *config.Feed) (PersistedStorage, error)

func NewVerifyingStorage

func NewVerifyingStorage(backingStorage PersistedStorage) PersistedStorage

NewVerifyingStorage returns a wrapper around any PersistedStorage that performs data validation when Putting data.

When streaming the data to the underlying PersistedStorage, the wrapper calculates an MD5 checksum of the data. After the underlying storage returns, it re-reads the data in full and verifies the checksums match.

Methods other than Put invoke the underlying type directly.

type Prefix

type Prefix []string

func EmptyPrefix

func EmptyPrefix() Prefix

func (Prefix) ID

func (p Prefix) ID() string

func (Prefix) IsParent

func (p Prefix) IsParent(p2 Prefix) bool

type SearchResult

type SearchResult struct {
	Prefix Prefix
	Names  []string
}

Jump to

Keyboard shortcuts

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