storer

package
v0.0.0-...-bd8fb77 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DirPlaceholder = []byte("init_dir")
)

Functions

func ClrearStores

func ClrearStores()

func FromatKey

func FromatKey(key, prefix string) (string, string, string)

func InitStore

func InitStore(key string, opt GenericStoreOption, stg Interface) error

func InitStores

func InitStores(stg Interface) (err error)

Types

type EtcdV3

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

func NewEtcd

func NewEtcd(etcdConf *conf.Etcd) (*EtcdV3, error)

func (*EtcdV3) Close

func (s *EtcdV3) Close() error

Close the client connection

func (*EtcdV3) Create

func (s *EtcdV3) Create(ctx context.Context, key, value string) error

Create a value at the specified key

func (*EtcdV3) Delete

func (s *EtcdV3) Delete(ctx context.Context, key string) error

Delete a value at the specified key

func (*EtcdV3) DeletePrefix

func (s *EtcdV3) DeletePrefix(ctx context.Context, prefix string) error

DeletePrefix deletes a range of keys under a given prefix

func (*EtcdV3) Get

func (s *EtcdV3) Get(ctx context.Context, key string) (string, error)

Get a value given its key

func (*EtcdV3) List

func (s *EtcdV3) List(ctx context.Context, prefix string) ([]*message.Message, error)

List the content of a given prefix

func (*EtcdV3) Update

func (s *EtcdV3) Update(ctx context.Context, key, value string, version int64) error

Update a value at the specified key

func (*EtcdV3) Watch

func (s *EtcdV3) Watch(ctx context.Context, prefix string) <-chan []*message.Message

Watch for changes on a key

type GenericStore

type GenericStore struct {
	Typ string
	Stg Interface
	// contains filtered or unexported fields
}

func GetStore

func GetStore(entity string) *GenericStore

func GetStores

func GetStores() []*GenericStore

func NewGenericStore

func NewGenericStore(typ string, opt GenericStoreOption, stg Interface) (*GenericStore, error)

func (*GenericStore) BasePath

func (s *GenericStore) BasePath() string

func (*GenericStore) Delete

func (s *GenericStore) Delete(key string) (interface{}, bool)

func (*GenericStore) List

func (s *GenericStore) List(filter func(*message.Message) bool) ([]*message.Message, error)

func (*GenericStore) Store

func (s *GenericStore) Store(key string, objPtr interface{}) (interface{}, bool)

func (*GenericStore) Unwatch

func (s *GenericStore) Unwatch()

func (*GenericStore) UpdateNodes

func (s *GenericStore) UpdateNodes(ctx context.Context, msg *message.Message) (err error)

func (*GenericStore) Watch

func (s *GenericStore) Watch() <-chan []*message.Message

type GenericStoreOption

type GenericStoreOption struct {
	BasePath string
	Prefix   string
}

type Interface

type Interface interface {
	List(context.Context, string) ([]*message.Message, error)
	Update(context.Context, string, string, int64) error
	Watch(context.Context, string) <-chan []*message.Message
}

type MockInterface

type MockInterface struct {
	mock.Mock
}

func (*MockInterface) List

func (m *MockInterface) List(_ context.Context, key string) ([]*message.Message, error)

func (*MockInterface) Update

func (m *MockInterface) Update(_ context.Context, key, value string, version int64) error

func (*MockInterface) Watch

func (m *MockInterface) Watch(_ context.Context, key string) <-chan []*message.Message

Jump to

Keyboard shortcuts

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