store

package
Version: v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UnknownIndex = errors.New(`index does not exist`)

Functions

func MakeEndpoints

func MakeEndpoints(host string, registry Registry, logger log.Logger)

Types

type Builder

type Builder func(name string, keyEncoder, valEncoder encoding.Builder, options ...Options) (Store, error)

type Err

type Err struct {
	Err string `json:"error"`
}

type Index

type Index interface {
	String() string
	Write(key, value interface{}) error
	WriteHash(hash, key interface{}) error
	Hash(key, val interface{}) (hash interface{})
	Delete(key, value interface{}) error
	Read(index interface{}) ([]interface{}, error)
	Keys() []interface{}
	Values() map[interface{}][]interface{}
	ValueIndexed(index, value interface{}) (bool, error)
}

func NewIndex added in v1.2.50

func NewIndex(name string, mapper func(key, val interface{}) (idx interface{})) Index

func NewStringHashIndex

func NewStringHashIndex(name string, mapper KeyMapper) Index

func NewUuidHashIndex

func NewUuidHashIndex(name string, mapper func(key, val interface{}) (idx uuid.UUID)) Index

type IndexedStore

type IndexedStore interface {
	Store
	GetIndex(ctx context.Context, name string) (Index, error)
	Indexes() []Index
	GetIndexedRecords(ctx context.Context, index string, key interface{}) ([]interface{}, error)
}

func NewIndexedStore

func NewIndexedStore(name string, keyEncoder, valEncoder encoding.Encoder, indexes []Index, options ...Options) (IndexedStore, error)

type IndexedStoreBuilder added in v1.2.50

type IndexedStoreBuilder func(name string, keyEncoder, valEncoder encoding.Builder, indexes []Index, options ...Options) (IndexedStore, error)

type Iterator

type Iterator interface {
	SeekToFirst()
	SeekToLast()
	Seek(key interface{}) error
	Next()
	Prev()
	Close()
	Key() (interface{}, error)
	Value() (interface{}, error)
	Valid() bool
	Error() error
}

type KeyMapper

type KeyMapper func(key, val interface{}) (idx string)

type Meta

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

func NewMata

func NewMata(c sarama.Client, group string) *Meta

func (*Meta) GetMeta

func (m *Meta) GetMeta(tp string) string

func (*Meta) Refresh

func (m *Meta) Refresh()

type MockRecord

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

type MockStore

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

func (*MockStore) Backend

func (s *MockStore) Backend() backend.Backend

func (*MockStore) Delete

func (s *MockStore) Delete(ctx context.Context, key interface{}) error

func (*MockStore) Get

func (s *MockStore) Get(ctx context.Context, key interface{}) (value interface{}, err error)

func (*MockStore) GetAll

func (*MockStore) GetAll(ctx context.Context) (Iterator, error)

func (*MockStore) GetRange

func (*MockStore) GetRange(ctx context.Context, fromKey interface{}, toKey interface{}) (map[interface{}]interface{}, error)

func (*MockStore) KeyEncoder

func (s *MockStore) KeyEncoder() encoding.Encoder

func (*MockStore) Name

func (s *MockStore) Name() string

func (*MockStore) Set

func (s *MockStore) Set(ctx context.Context, key interface{}, value interface{}, expiry time.Duration) error

func (*MockStore) String

func (s *MockStore) String() string

func (*MockStore) ValEncoder

func (s *MockStore) ValEncoder() encoding.Encoder

type Options

type Options func(config *storeOptions)

func Buffered

func Buffered(size int) Options

func ChangelogEnabled

func ChangelogEnabled() Options

func Compacated

func Compacated() Options

func Expire

func Expire(d time.Duration) Options

func WithBackend

func WithBackend(backend backend.Backend) Options

func WithBackendBuilder

func WithBackendBuilder(builder backend.Builder) Options

func WithChangelog

func WithChangelog(changelog changelog.Changelog) Options

func WithLogger

func WithLogger(logger log.Logger) Options

type RecoverableStore

type RecoverableStore interface {
	Store
	Recover(ctx context.Context) error
}

type Registry

type Registry interface {
	Register(store Store)
	New(name string, keyEncoder, valEncoder encoding.Builder, options ...Options) Store
	NewIndexedStore(name string, keyEncoder, valEncoder encoding.Builder, indexes []Index, options ...Options) IndexedStore
	Store(name string) (Store, error)
	Index(name string) (Index, error)
	Stores() []Store
	Indexes() []Index
}

func NewRegistry

func NewRegistry(config *RegistryConfig) Registry

type RegistryConfig

type RegistryConfig struct {
	Host        string
	HttpEnabled bool

	StoreBuilder        Builder
	StateStoreBuilder   StateStoreBuilder
	IndexedStoreBuilder IndexedStoreBuilder
	Logger              log.Logger
	MetricsReporter     metrics.Reporter
	// contains filtered or unexported fields
}

type StateStore

type StateStore interface {
	Name() string
	Set(key, value interface{}) error
	Get(key interface{}) (value interface{}, err error)
	GetAll() ([]*data.Record, error)
}

func NewStateStore

func NewStateStore(name string, keyEncoder encoding.Encoder, valEncoder encoding.Encoder, options ...Options) StateStore

type StateStoreBuilder

type StateStoreBuilder func(name string, keyEncoder, valEncoder encoding.Builder, options ...Options) StateStore

type Store

type Store interface {
	Name() string
	Backend() backend.Backend
	KeyEncoder() encoding.Encoder
	ValEncoder() encoding.Encoder
	Set(ctx context.Context, key, value interface{}, expiry time.Duration) error
	Get(ctx context.Context, key interface{}) (value interface{}, err error)
	GetRange(ctx context.Context, fromKey, toKey interface{}) (map[interface{}]interface{}, error)
	GetAll(ctx context.Context) (Iterator, error)
	Delete(ctx context.Context, key interface{}) error
	String() string
}

func NewMockStore

func NewMockStore(name string, kEncode encoding.Encoder, vEncoder encoding.Encoder, backend backend.Backend, records ...MockRecord) Store

func NewStore

func NewStore(name string, keyEncoder encoding.Encoder, valEncoder encoding.Encoder, options ...Options) (Store, error)

Jump to

Keyboard shortcuts

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