persist

package
v2.0.0-...-675b67f Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OffsetsBucket = []byte(`offsets`)

OffsetsBucket is the scope provided to offset persistence

Functions

func NewBBoltPersister

func NewBBoltPersister(filePath string) (*BBoltPersister, PersisterShutdownFunc, error)

NewBBoltPersister opens a connection to a bbolt database for the given filePath and wraps it in a Scopped Persister. scope refers to a bbolt bucket name

Types

type BBoltPersister

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

BBoltPersister is a persister that uses a database for the backend

func (*BBoltPersister) Clear

func (p *BBoltPersister) Clear() error

Clear clears the offset bucket of all data

func (*BBoltPersister) Delete

func (p *BBoltPersister) Delete(_ context.Context, key string) error

Delete removes the key from the bbolt scoped bucket

func (*BBoltPersister) Get

func (p *BBoltPersister) Get(_ context.Context, key string) ([]byte, error)

Get returns the data associated with the key

func (*BBoltPersister) Keys

func (p *BBoltPersister) Keys() ([]string, error)

Keys returns all the keys associated with the bbolt db backing this persister

func (*BBoltPersister) Set

func (p *BBoltPersister) Set(_ context.Context, key string, value []byte) error

Set sets the data associated with the key to the bbolt scoped bucket

type CachedPersister

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

CachedPersister implements a cache on top of a persister

func NewCachedPersister

func NewCachedPersister(p operator.Persister) *CachedPersister

NewCachedPersister creates a Cache Persister that wraps the supplied Persister in a cache

func (*CachedPersister) Delete

func (p *CachedPersister) Delete(ctx context.Context, key string) error

func (*CachedPersister) Get

func (p *CachedPersister) Get(ctx context.Context, key string) ([]byte, error)

Get retrieves data from cache. If not found falls through to underlying persister to retrieve data

func (*CachedPersister) Set

func (p *CachedPersister) Set(ctx context.Context, key string, value []byte) error

Set sets value for key in cache and falls through to the underlying Persister

type NoopPersister

type NoopPersister struct{}

NoopPersister is a persister that does nothing and returns no errors

func (*NoopPersister) Delete

func (p *NoopPersister) Delete(_ context.Context, _ string) error

Delete does nothing and returns no error

func (*NoopPersister) Get

func (p *NoopPersister) Get(_ context.Context, _ string) ([]byte, error)

Get does nothing and returns no error

func (*NoopPersister) Set

func (p *NoopPersister) Set(_ context.Context, _ string, _ []byte) error

Set does nothing and returns no error

type PersisterShutdownFunc

type PersisterShutdownFunc func() error

PersisterShutdownFunc handles cleanup of the persister

var NoopShutdownFunc PersisterShutdownFunc = func() error {
	return nil
}

NoopShutdownFunc is a PersisterShutdownFunc that returns nil. To be used with persisters that have no shutdown operation

Jump to

Keyboard shortcuts

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