formattedstore

package module
v0.0.0-...-22156a9 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FormattedProvider

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

FormattedProvider is a newstorage.Provider that allows for data to be formatted in an underlying provider.

func NewProvider

func NewProvider(underlyingProvider newstorage.Provider, formatter Formatter, options ...Option) *FormattedProvider

NewProvider instantiates a new FormattedProvider with the given newstorage.Provider and Formatter. The Formatter is used to format data before being sent to the Provider for storage. The Formatter is also used to restore the original format of data being retrieved from Provider.

func (*FormattedProvider) Close

func (f *FormattedProvider) Close() error

Close closes all stores created under this store provider. For persistent store implementations, this does not delete any data in the underlying stores.

func (*FormattedProvider) GetOpenStores

func (f *FormattedProvider) GetOpenStores() []newstorage.Store

GetOpenStores returns all currently open stores.

func (*FormattedProvider) GetStoreConfig

func (f *FormattedProvider) GetStoreConfig(name string) (newstorage.StoreConfiguration, error)

GetStoreConfig gets the current store configuration. The store must be created prior to calling this method. If the store cannot be found, then an error wrapping ErrStoreNotFound will be returned.

func (*FormattedProvider) OpenStore

func (f *FormattedProvider) OpenStore(name string) (newstorage.Store, error)

OpenStore opens a store with the given name and returns a handle. If the store has never been opened before, then it is created. Store names are not case-sensitive.

func (*FormattedProvider) SetStoreConfig

func (f *FormattedProvider) SetStoreConfig(name string, config newstorage.StoreConfiguration) error

SetStoreConfig sets the configuration on a store. The store must be created prior to calling this method. If the store cannot be found, then an error wrapping newstorage.ErrStoreNotFound will be returned from the underlying provider.

type Formatter

type Formatter interface {
	Format(key string, value []byte, tags ...newstorage.Tag) (formattedKey string, formattedValue []byte,
		formattedTags []newstorage.Tag, err error)
	Deformat(formattedKey string, formattedValue []byte, formattedTags ...newstorage.Tag) (key string, value []byte,
		tags []newstorage.Tag, err error)
}

Formatter represents a type that can convert data between two formats.

type Option

type Option func(opts *FormattedProvider)

Option represents an option for a FormattedProvider.

func WithCacheProvider

func WithCacheProvider(cacheProvider newstorage.Provider) Option

WithCacheProvider option enables a cache for a FormatProvider. This cache will hold unformatted data, which can result in a performance improvement in cases where the formatting operation is expensive. Tags are never cached, so any retrieval operations that require them will always skip the cache. They cannot be cached efficiently from store.Get calls since getting tags would require a separate call to the main provider, and Query calls have to skip the cache anyway in order to make sure that no uncached data is missed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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