kv

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResultCodeFailure = iota
	ResultCodeSuccess
	ResultCodeVersionMismatch
)
View Source
const (
	UpdateOpSet    = "set"
	UpdateOpDelete = "delete"
)

Variables

View Source
var (
	// ErrNotExist key does not exist in the store.
	ErrNotExist = errors.New("key does not exist")
	// ErrVersionMismatch version provided does not match the version stored.
	ErrVersionMismatch = errors.New("version mismatch")
)

Functions

Types

type LFSM

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

func (*LFSM) Close

func (fsm *LFSM) Close() (err error)

func (*LFSM) Lookup

func (fsm *LFSM) Lookup(e interface{}) (interface{}, error)

func (*LFSM) PrepareSnapshot

func (fsm *LFSM) PrepareSnapshot() (interface{}, error)

func (*LFSM) RecoverFromSnapshot

func (fsm *LFSM) RecoverFromSnapshot(r io.Reader, _ []dbsm.SnapshotFile, _ <-chan struct{}) error

func (*LFSM) SaveSnapshot

func (fsm *LFSM) SaveSnapshot(ctx interface{}, w io.Writer, _ dbsm.ISnapshotFileCollection, _ <-chan struct{}) error

func (*LFSM) Update

func (fsm *LFSM) Update(entries []dbsm.Entry) ([]dbsm.Entry, error)

type MapStore

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

A MapStore represents an in-memory key-value store safe for concurrent access.

func NewMapStore

func NewMapStore() *MapStore

NewMapStore creates and initializes a new MapStore.

func (*MapStore) Delete

func (s *MapStore) Delete(key string, ver uint64) error

Delete deletes the Pair associated with key.

func (*MapStore) Exists

func (s *MapStore) Exists(key string) (bool, error)

Exists checks for the existence of key in the store.

func (*MapStore) Get

func (s *MapStore) Get(key string) (Pair, error)

Get gets the Pair associated with key. If there is no Pair associated with key, Get returns Pair{}, ErrNotExist.

func (*MapStore) GetAll

func (s *MapStore) GetAll(pattern string) ([]Pair, error)

GetAll returns a Pair for all nodes with keys matching pattern. The syntax of patterns is the same as in path.Match.

func (*MapStore) GetAllValues

func (s *MapStore) GetAllValues(pattern string) ([]string, error)

GetAllValues returns a []string for all nodes with keys matching pattern. The syntax of patterns is the same as in path.Match.

func (*MapStore) List

func (s *MapStore) List(filePath string) ([]string, error)

func (*MapStore) ListDir

func (s *MapStore) ListDir(filePath string) ([]string, error)

func (*MapStore) MarshalJSON added in v0.2.0

func (s *MapStore) MarshalJSON() ([]byte, error)

func (*MapStore) Set

func (s *MapStore) Set(key string, value string, ver uint64) (Pair, error)

Set sets the Pair entry associated with key to value.

func (*MapStore) UnmarshalJSON added in v0.2.0

func (s *MapStore) UnmarshalJSON(bytes []byte) error

type Pair

type Pair struct {
	// Key a full path in KV store.
	Key string
	// Value a value assigned to the Key.
	Value string
	// Ver a key version, version must be supplied for consecutive updates.
	Ver uint64
}

Pair represents a single versioned KV pair.

type QueryAll

type QueryAll struct {
	Pattern string
}

type QueryAllValues

type QueryAllValues struct {
	Pattern string
}

type QueryExist added in v0.2.0

type QueryExist struct {
	Key string
}

type QueryKey

type QueryKey struct {
	Key string
}

type QueryList

type QueryList struct {
	Path string
}

type QueryListDir

type QueryListDir struct {
	Path string
}

type RaftConfig added in v0.5.0

type RaftConfig struct {
	NodeID             uint64
	ElectionRTT        uint64
	HeartbeatRTT       uint64
	SnapshotEntries    uint64
	CompactionOverhead uint64
	MaxInMemLogSize    uint64
	InitialMembers     map[uint64]dragonboat.Target
}

type RaftStore

type RaftStore struct {
	NodeHost  *dragonboat.NodeHost
	ClusterID uint64
}

func (*RaftStore) Delete

func (r *RaftStore) Delete(key string, ver uint64) error

func (*RaftStore) Exists

func (r *RaftStore) Exists(key string) (bool, error)

func (*RaftStore) Get

func (r *RaftStore) Get(key string) (Pair, error)

func (*RaftStore) GetAll

func (r *RaftStore) GetAll(pattern string) ([]Pair, error)

func (*RaftStore) GetAllValues

func (r *RaftStore) GetAllValues(pattern string) ([]string, error)

func (*RaftStore) HasLeader added in v0.5.0

func (r *RaftStore) HasLeader() bool

func (*RaftStore) List

func (r *RaftStore) List(filePath string) ([]string, error)

func (*RaftStore) ListDir

func (r *RaftStore) ListDir(filePath string) ([]string, error)

func (*RaftStore) Set

func (r *RaftStore) Set(key string, value string, ver uint64) (Pair, error)

Set sets the Pair entry associated with key to value and checks the version while doing so.

func (*RaftStore) Start added in v0.5.0

func (r *RaftStore) Start(cfg RaftConfig) error

func (*RaftStore) WaitForLeader added in v0.5.0

func (r *RaftStore) WaitForLeader(ctx context.Context) error

type Update

type Update struct {
	Op     string
	KVPair Pair
}

Jump to

Keyboard shortcuts

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