kv

package
v3.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEtcdKVBase

func NewEtcdKVBase(client *clientv3.Client, rootPath string) *etcdKVBase

NewEtcdKVBase creates a new etcd kv.

func NewSlowLogTxn

func NewSlowLogTxn(client *clientv3.Client) clientv3.Txn

NewSlowLogTxn create a SlowLogTxn.

Types

type Base

type Base interface {
	Load(key string) (string, error)
	LoadRange(key, endKey string, limit int) (keys []string, values []string, err error)
	Save(key, value string) error
	Remove(key string) error
}

Base is an abstract interface for load/save pd cluster data.

func NewMemoryKV

func NewMemoryKV() Base

NewMemoryKV returns an in-memory kvBase for testing.

type LeveldbKV

type LeveldbKV struct {
	*leveldb.DB
}

LeveldbKV is a kv store using leveldb.

func NewLeveldbKV

func NewLeveldbKV(path string) (*LeveldbKV, error)

NewLeveldbKV is used to store regions information.

func (*LeveldbKV) Load

func (kv *LeveldbKV) Load(key string) (string, error)

Load gets a value for a given key.

func (*LeveldbKV) LoadRange

func (kv *LeveldbKV) LoadRange(startKey, endKey string, limit int) ([]string, []string, error)

LoadRange gets a range of value for a given key range.

func (*LeveldbKV) Remove

func (kv *LeveldbKV) Remove(key string) error

Remove deletes a key-value pair for a given key.

func (*LeveldbKV) Save

func (kv *LeveldbKV) Save(key, value string) error

Save stores a key-value pair.

func (*LeveldbKV) SaveRegions

func (kv *LeveldbKV) SaveRegions(regions map[string]*metapb.Region) error

SaveRegions stores some regions.

type SlowLogTxn

type SlowLogTxn struct {
	clientv3.Txn
	// contains filtered or unexported fields
}

SlowLogTxn wraps etcd transaction and log slow one.

func (*SlowLogTxn) Commit

func (t *SlowLogTxn) Commit() (*clientv3.TxnResponse, error)

Commit implements Txn Commit interface.

func (*SlowLogTxn) If

func (t *SlowLogTxn) If(cs ...clientv3.Cmp) clientv3.Txn

If takes a list of comparison. If all comparisons passed in succeed, the operations passed into Then() will be executed. Or the operations passed into Else() will be executed.

func (*SlowLogTxn) Then

func (t *SlowLogTxn) Then(ops ...clientv3.Op) clientv3.Txn

Then takes a list of operations. The Ops list will be executed, if the comparisons passed in If() succeed.

Jump to

Keyboard shortcuts

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