state

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPrefix = "/"

Variables

View Source
var (
	ErrReceiverNotAPointer = errors.New("receiver is not a pointer")
	ErrReceiverNotASlice   = errors.New("receiver is not a slice")
)

Functions

This section is empty.

Types

type BadgerTransaction

type BadgerTransaction interface {
	NewIterator(opt badger.IteratorOptions) *badger.Iterator
	Get(key []byte) (item *badger.Item, rerr error)
	SetEntry(e *badger.Entry) error
}

type Decoder

type Decoder interface {
	Decode(data []byte, v interface{}) error
}

type Encoder

type Encoder interface {
	Encode(v interface{}) (data []byte, err error)
}

type EncoderDecoder

type EncoderDecoder interface {
	Encoder
	Decoder
}

type KVStore

type KVStore interface {
	TxnReaderWriter
	io.Closer
	ReadOnlyTransaction(ops func(reader TxnReader) error) error
	ReadWriteTransaction(ops func(rw TxnReaderWriter) error) error
	WithSuffixes(suffixes ...string) KVStore
}

type Logger

type Logger struct {
	*zap.SugaredLogger
}

func (Logger) Debugf

func (l Logger) Debugf(s string, i ...interface{})

func (Logger) Errorf

func (l Logger) Errorf(s string, i ...interface{})

func (Logger) Infof

func (l Logger) Infof(s string, i ...interface{})

func (Logger) Warningf

func (l Logger) Warningf(s string, i ...interface{})

type MsgPackEncoding

type MsgPackEncoding struct{}

func (MsgPackEncoding) Decode

func (m MsgPackEncoding) Decode(data []byte, v interface{}) error

func (MsgPackEncoding) Encode

func (m MsgPackEncoding) Encode(v interface{}) (data []byte, err error)

type SetOption

type SetOption interface {
	Apply(e *badger.Entry)
}

type SetOptionFunc

type SetOptionFunc func(e *badger.Entry)

func (SetOptionFunc) Apply

func (f SetOptionFunc) Apply(e *badger.Entry)

type Store

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

func NewDefault

func NewDefault(opts ...StoreOption) (*Store, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) Get

func (s *Store) Get(key string, v interface{}) error

func (*Store) GetAll

func (s *Store) GetAll(prefix string, into interface{}) error

func (*Store) ReadOnlyTransaction

func (s *Store) ReadOnlyTransaction(ops func(reader TxnReader) error) error

func (*Store) ReadWriteTransaction

func (s *Store) ReadWriteTransaction(ops func(rw TxnReaderWriter) error) error

func (*Store) Set

func (s *Store) Set(key string, v interface{}, opts ...SetOption) error

func (*Store) WithSuffixes

func (s *Store) WithSuffixes(suffixes ...string) KVStore

type StoreOption

type StoreOption interface {
	Apply(opt *StoreOptions)
}

func WithEncoding

func WithEncoding(encoding EncoderDecoder) StoreOption

func WithInMemory

func WithInMemory() StoreOption

func WithLogger

func WithLogger(logger badger.Logger) StoreOption

func WithPath

func WithPath(filePath string) StoreOption

type StoreOptionFunc

type StoreOptionFunc func(opt *StoreOptions)

func (StoreOptionFunc) Apply

func (f StoreOptionFunc) Apply(opt *StoreOptions)

type StoreOptions

type StoreOptions struct {
	FilePath string
	InMemory bool
	Encoding EncoderDecoder
	Logger   badger.Logger
}

type TestLogger

type TestLogger struct {
	testing.TB
}

func (TestLogger) Debugf

func (l TestLogger) Debugf(s string, i ...interface{})

func (TestLogger) Errorf

func (l TestLogger) Errorf(s string, i ...interface{})

func (TestLogger) Infof

func (l TestLogger) Infof(s string, i ...interface{})

func (TestLogger) Warningf

func (l TestLogger) Warningf(s string, i ...interface{})

type TxnReader

type TxnReader interface {
	Get(key string, v interface{}) error
	GetAll(prefix string, into interface{}) error
}

type TxnReaderWriter

type TxnReaderWriter interface {
	TxnReader
	TxnWriter
}

type TxnWriter

type TxnWriter interface {
	Set(key string, v interface{}, opts ...SetOption) error
}

type WithTTL

type WithTTL time.Duration

func (WithTTL) Apply

func (t WithTTL) Apply(e *badger.Entry)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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