stores

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteIndexes

func DeleteIndexes(ctx context.Context, store IndexedStore, key interface{}) error

func MakeEndpoints

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

func UpdateIndexes

func UpdateIndexes(ctx context.Context, store IndexedStore, key, val interface{}) error

Types

type Builder

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

type Cache

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

func (*Cache) Backend

func (c *Cache) Backend() backend.Cache

func (*Cache) Close

func (c *Cache) Close() error

func (*Cache) Delete

func (c *Cache) Delete(ctx context.Context, key interface{}) error

func (*Cache) Flush

func (c *Cache) Flush() error

func (*Cache) Get

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

func (*Cache) Iterator

func (c *Cache) Iterator(ctx context.Context) (Iterator, error)

func (*Cache) PrefixedIterator

func (c *Cache) PrefixedIterator(ctx context.Context, keyPrefix interface{}, prefixEncoder encoding.Encoder) (Iterator, error)

func (*Cache) Reset

func (c *Cache) Reset()

func (*Cache) Set

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

type Closable

type Closable interface {
	Close() error
}

type Err

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

type IdxBuilder

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

func NewIndex

func NewIndex(name string, mapper KeyMapper) *IdxBuilder

func (*IdxBuilder) Build

func (idb *IdxBuilder) Build(store ReadOnlyStore, backend backend.Builder, keyEncoder encoding.Encoder) (Index, error)

func (*IdxBuilder) Name added in v2.0.1

func (idb *IdxBuilder) Name() string

type Index

type Index interface {
	sync.Locker
	String() string
	Write(key, value interface{}) error
	KeyPrefixer(key, value interface{}) (hash string)
	Delete(key, value interface{}) error
	Read(index string) (backend.Iterator, error)
	Values(key string) ([]string, error)
	Keys() ([]string, error)
	Compare(key interface{}, valBefore, valAfter interface{}) (bool, error)
	KeyIndexed(index string, key interface{}) (bool, error)
	Backend() backend.Backend
	Close() error
}

type IndexBuilder

type IndexBuilder interface {
	Name() string
	Build(store ReadOnlyStore, backend backend.Builder, keyEncoder encoding.Encoder) (Index, error)
}

type IndexedStore

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

func NewIndexedStore

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

type IndexedStoreBuilder

type IndexedStoreBuilder func(name string, keyEncoder, valEncoder encoding.Encoder, indexes []IndexBuilder, options ...Option) (IndexedStore, error)

type Iterator

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

func NewIterator

func NewIterator(backendItr backend.Iterator, keyEnc, valEnc encoding.Encoder) Iterator

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 Option

type Option func(config *StoreOptions)

func Buffered

func Buffered(size int) Option

func Compacated

func Compacated() Option

func WithBackend

func WithBackend(backend backend.Backend) Option

func WithBackendBuilder

func WithBackendBuilder(builder backend.Builder) Option

func WithCachingEnabled

func WithCachingEnabled() Option

func WithVersionExtractor

func WithVersionExtractor(etc RecordVersionExtractor) Option

func WithVersionWriter

func WithVersionWriter(wr RecordVersionWriter) Option

type ReadOnlyStore

type ReadOnlyStore interface {
	Name() string
	KeyEncoder() encoding.Encoder
	ValEncoder() encoding.Encoder
	Get(ctx context.Context, key interface{}) (value interface{}, err error)
	Iterator(ctx context.Context) (Iterator, error)
	PrefixedIterator(ctx context.Context, keyPrefix interface{}, prefixEncoder encoding.Encoder) (Iterator, error)
	String() string
	Close() error
}

type RecordVersionExtractor

type RecordVersionExtractor func(ctx context.Context, key, value interface{}) (version int64, err error)

type RecordVersionWriter

type RecordVersionWriter func(ctx context.Context, version int64, vIn interface{}) (vOut interface{}, err error)

type Registry

type Registry interface {
	Register(store ReadOnlyStore) error
	RegisterDynamic(name string, lister StateStoresLister) error
	Create(name string, keyEncoder, valEncoder encoding.Encoder, options ...Option) (Store, error)
	CreateOrReturn(name string, keyEncoder encoding.Encoder, valEncoder encoding.Encoder, options ...Option) (Store, error)
	NewIndexedStore(name string, keyEncoder, valEncoder encoding.Encoder, indexes []IndexBuilder, options ...Option) IndexedStore
	NewBuilder(name string, keyEncoder, valEncoder encoding.Encoder, options ...Option) StoreBuilder
	Store(name string) (ReadOnlyStore, error)
	Builder(name string) (StoreBuilder, error)
	Index(name string) (Index, error)
	Stores() []ReadOnlyStore
	StartWebServer()
	Builders() []StoreBuilder
	Indexes() []Index
}

func NewRegistry

func NewRegistry(config *RegistryConfig) Registry

type RegistryConfig

type RegistryConfig struct {
	Host        string
	HttpEnabled bool

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

type StateStoresLister

type StateStoresLister func() []ReadOnlyStore

type Store

type Store interface {
	Backend() backend.Backend
	Set(ctx context.Context, key, value interface{}, expiry time.Duration) error
	Delete(ctx context.Context, key interface{}) error
	Flush() error
	Cache() StoreCache
	ReadOnlyStore
}

func NewStore

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

type StoreBuilder

type StoreBuilder interface {
	Name() string
	Build(name string, options ...Option) (Store, error)
}

func NewDefaultStoreBuilder

func NewDefaultStoreBuilder(name string, keyEncoder encoding.Encoder, valEncoder encoding.Encoder, options ...Option) StoreBuilder

type StoreCache

type StoreCache interface {
	Get(ctx context.Context, key interface{}) (value interface{}, err error)
	Iterator(ctx context.Context) (Iterator, error)
	PrefixedIterator(ctx context.Context, keyPrefix interface{}, prefixEncoder encoding.Encoder) (Iterator, error)
	Set(ctx context.Context, key, value interface{}, expiry time.Duration) error
	Delete(ctx context.Context, key interface{}) error
	Flush() error
	Close() error
	Reset()
	Backend() backend.Cache
}

type StoreOptions

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

Jump to

Keyboard shortcuts

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