storetypes

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package storetypes define jsonstore public types

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeType

type ChangeType int

ChangeType kv 变化类型

const (
	// Add 新增 kv
	Add ChangeType = iota
	// Del 删除 kv
	Del
	// Update 更新 kv
	Update
)

func (ChangeType) String

func (c ChangeType) String() string

type Key

type Key []byte

Key key 类型

type KeyValue

type KeyValue struct {
	Key         []byte
	Value       []byte
	Revision    int64
	ModRevision int64
}

KeyValue kv 类型,如果不是etcd backend,Revision 和 ModRevision 可能为空

type KeyValueWithChangeType

type KeyValueWithChangeType struct {
	KeyValue
	T ChangeType
}

KeyValueWithChangeType = KeyValue + ChangeType

type Store

type Store interface {
	Put(ctx context.Context, key, value string) error
	Get(ctx context.Context, key string) (KeyValue, error)
	Remove(ctx context.Context, key string) (*KeyValue, error)
	PrefixRemove(pctx context.Context, prefix string) ([]KeyValue, error)
	PrefixGet(ctx context.Context, prefix string) ([]KeyValue, error)
	PrefixGetKey(ctx context.Context, prefix string) ([]Key, error)

	PutWithOption(ctx context.Context, key, value string, opts []interface{}) (interface{}, error)
}

Store 包括了实现 backend 所需的基本接口

type StoreWithSTM

type StoreWithSTM interface {
	Store
	stm.JSONStoreSTM
}

StoreWithSTM = Store + STM

type StoreWithWatch

type StoreWithWatch interface {
	Store
	Watch(ctx context.Context, key string, isPrefix bool, filterDelete bool) (WatchChan, error)
}

StoreWithWatch = Store + Watch

type WatchChan

type WatchChan <-chan WatchResponse

WatchChan watchResponse chan

type WatchResponse

type WatchResponse struct {
	Kvs []KeyValueWithChangeType
	Err error
}

WatchResponse watch 到的 kv 变化结果

Jump to

Keyboard shortcuts

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