formattedstore

package
v0.1.6-0...-5c25bcb Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrValueIsDeleted = fmt.Errorf("value is deleted")

ErrValueIsDeleted is returned when value is deleted.

Functions

This section is empty.

Types

type BatchService

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

BatchService is a batch service.

func NewBatchWrite

func NewBatchWrite(batchSizeLimit int, formatter Formatter, provider batchProvider) *BatchService

NewBatchWrite new batch write. nolint: funlen

func (*BatchService) Delete

func (b *BatchService) Delete(k string) error

Delete value.

func (*BatchService) Flush

func (b *BatchService) Flush() error

Flush data.

func (*BatchService) Get

func (b *BatchService) Get(k string) ([]byte, error)

Get value from batch values.

func (*BatchService) Put

func (b *BatchService) Put(s batchStore, k string, v []byte) error

Put in batch value.

type FormattedProvider

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

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

func NewFormattedProvider

func NewFormattedProvider(provider storage.Provider, formatter Formatter,
	skipIteratorFiltering bool, opts ...Option) *FormattedProvider

NewFormattedProvider instantiates a new FormattedProvider with the given 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. If the underlying provider already does filtering using the startKey and endKey parameters in its Iterator(startKey, endKey string) method, then set skipIteratorFiltering to true to avoid redundant filtering in FormattedProvider.

func (*FormattedProvider) Close

func (p *FormattedProvider) Close() error

Close closes all stores created in the underlying provider.

func (*FormattedProvider) CloseStore

func (p *FormattedProvider) CloseStore(name string) error

CloseStore closes the store with the given name in the underlying provider.

func (*FormattedProvider) Flush

func (p *FormattedProvider) Flush() error

Flush call batch svc to flush data. TODO this method need to be refactored.

func (*FormattedProvider) OpenStore

func (p *FormattedProvider) OpenStore(name string) (storage.Store, error)

OpenStore opens a store in the underlying provider with the given name and returns a handle to it.

type Formatter

type Formatter interface {
	FormatPair(k string, v []byte) ([]byte, error)
	ParsePair([]byte) (k string, v []byte, err error)
	GenerateEDVDocumentID(k string) (string, error)
}

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

type Option

type Option func(opts *FormattedProvider)

Option configures the formatted store.

func WithBatchWrite

func WithBatchWrite(batchSize int) Option

WithBatchWrite option is for batch write.

func WithCacheProvider

func WithCacheProvider(cacheProvider storage.Provider) Option

WithCacheProvider option is for using caching provider.

Jump to

Keyboard shortcuts

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