jsonstore

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: AGPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotFoundErr = errors.New("not found")
)

Functions

This section is empty.

Types

type BackendType

type BackendType = int
const (
	EtcdStore BackendType = iota
	MemStore
	MemEtcdStore
	CacheEtcdStore
)

type JSONStoreWithSTM

type JSONStoreWithSTM interface {
	JsonStore
	stm.JSONStoreSTM
}

type JSONStoreWithSTMImpl

type JSONStoreWithSTMImpl struct {
	JsonStore
	// contains filtered or unexported fields
}

func (*JSONStoreWithSTMImpl) NewSTM

func (j *JSONStoreWithSTMImpl) NewSTM(f func(stm stm.JSONStoreSTMOP) error) error

type JSONStoreWithWatch

type JSONStoreWithWatch interface {
	JsonStore
	Watch(ctx context.Context, key string, isPrefix bool, filterDelete bool, keyonly bool, object interface{}, handle func(string, interface{}, storetypes.ChangeType) error) error
}

type JSONStoreWithWatchImpl

type JSONStoreWithWatchImpl struct {
	JsonStore
	// contains filtered or unexported fields
}

func (*JSONStoreWithWatchImpl) Watch

func (j *JSONStoreWithWatchImpl) Watch(ctx context.Context, key string, isPrefix bool, filterDelete bool, keyonly bool, object interface{}, handle func(string, interface{}, storetypes.ChangeType) error) error

TODO: refactor this method, use options, instead of so many bool values

type JsonStore

type JsonStore interface {
	Put(ctx context.Context, key string, object interface{}) error
	PutWithOption(ctx context.Context, key string, object interface{}, opts []interface{}) (interface{}, error)
	Get(ctx context.Context, key string, object interface{}) error
	Remove(ctx context.Context, key string, object interface{}) error
	PrefixRemove(ctx context.Context, prefix string) (int, error)
	ForEach(ctx context.Context, prefix string, object interface{}, handle func(string, interface{}) error) error
	ForEachRaw(ctx context.Context, prefix string, handle func(string, []byte) error) error
	ListKeys(ctx context.Context, prefix string) ([]string, error)
	Notfound(ctx context.Context, key string) (bool, error)

	IncludeSTM() JSONStoreWithSTM
	IncludeWatch() JSONStoreWithWatch
}

func New

func New(opts ...OptionOperator) (JsonStore, error)

type JsonStoreImpl

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

func (*JsonStoreImpl) ForEach

func (j *JsonStoreImpl) ForEach(ctx context.Context, prefix string, object interface{}, handle func(string, interface{}) error) error

func (*JsonStoreImpl) ForEachRaw

func (j *JsonStoreImpl) ForEachRaw(ctx context.Context, prefix string, handle func(string, []byte) error) error

func (*JsonStoreImpl) Get

func (j *JsonStoreImpl) Get(ctx context.Context, key string, object interface{}) error

func (*JsonStoreImpl) IncludeSTM

func (j *JsonStoreImpl) IncludeSTM() JSONStoreWithSTM

func (*JsonStoreImpl) IncludeWatch

func (j *JsonStoreImpl) IncludeWatch() JSONStoreWithWatch

func (*JsonStoreImpl) ListKeys

func (j *JsonStoreImpl) ListKeys(ctx context.Context, prefix string) ([]string, error)

func (*JsonStoreImpl) Notfound

func (j *JsonStoreImpl) Notfound(ctx context.Context, key string) (bool, error)

func (*JsonStoreImpl) PrefixRemove

func (j *JsonStoreImpl) PrefixRemove(ctx context.Context, prefix string) (int, error)

func (*JsonStoreImpl) Put

func (j *JsonStoreImpl) Put(ctx context.Context, key string, object interface{}) error

func (*JsonStoreImpl) PutWithOption

func (j *JsonStoreImpl) PutWithOption(ctx context.Context, key string, object interface{}, opts []interface{}) (interface{}, error)

func (*JsonStoreImpl) Remove

func (j *JsonStoreImpl) Remove(ctx context.Context, key string, object interface{}) error

type Option

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

func (*Option) Apply

func (op *Option) Apply(opts []OptionOperator)

func (*Option) GetBackend

func (op *Option) GetBackend() (storetypes.Store, error)

type OptionOperator

type OptionOperator func(*Option)

func UseCacheEtcdStore

func UseCacheEtcdStore(ctx context.Context, etcdDir string, cap int) OptionOperator

func UseEtcdStore

func UseEtcdStore() OptionOperator

func UseLruStore

func UseLruStore(cap int) OptionOperator

func UseMemEtcdStore

func UseMemEtcdStore(ctx context.Context, etcdDir string, cb func(k string, v interface{}, t storetypes.ChangeType), cbobj interface{}) OptionOperator

func UseMemStore

func UseMemStore() OptionOperator

func UseTimeoutStore

func UseTimeoutStore(timeout int) OptionOperator

timeout: second

Directories

Path Synopsis
LRU + Watch
LRU + Watch
Package etcd 是 jsonstore 使用 etcd 作为 backend 的实现
Package etcd 是 jsonstore 使用 etcd 作为 backend 的实现
内存 + etcd, 内存中的数据自动与 etcd 中同步
内存 + etcd, 内存中的数据自动与 etcd 中同步
Package stm impl jsonstore stm with etcd concurrency package
Package stm impl jsonstore stm with etcd concurrency package
Package storetypes define jsonstore public types
Package storetypes define jsonstore public types
重复插入key相同的value, 不更新该key的deadline
重复插入key相同的value, 不更新该key的deadline

Jump to

Keyboard shortcuts

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