key_value

package
v0.0.0-...-42737ae Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NullOperation = iota
	Set
	Delete
)

Variables

View Source
var (
	ErrFailedLSMLogBuild = errors.New("failed to build the raft log from the key/value provided")
	ErrFailedAnyCast     = errors.New("failed to cast the value to anypb")
	ErrFailedToMarshal   = errors.New("failed to marshal payload")
)
View Source
var (
	ErrFailedSet    = errors.New("failed to set key/value pair")
	ErrFailedList   = errors.New("failed to list all values for provided kind")
	ErrFailedDelete = errors.New("failed to delete by key for provided kind")
	ErrFailedGet    = errors.New("failed to get value for key")
)

Functions

This section is empty.

Types

type Controller

type Controller interface {
	chassis.ConsensusRegistrar
	raft.FSM

	KeyValue
}

func NewController

func NewController(model Model) Controller

type Key

type Key = string

Key is an alias to a string that identifies it's use as a key in the key/value store

type KeyValue

type KeyValue interface {
	Delete(log chassis.Logger, key string, value T) error
	Set(log chassis.Logger, key string, value T, timeout time.Duration) (*SetResponse, error)
	Get(log chassis.Logger, key string, value T) (T, error)
	List(log chassis.Logger, kind T) (map[string]T, error)
}

type Model

type Model interface {
	dbadger.Repository
	// Delete removes a key forever
	Delete(Key, T) error
	// Retrieve a value by it's key
	Get(Key, T) (T, error)
	// List takes in a key prefix, and returns a map
	// of all values that the key prefix matches
	List(T) (map[Key]T, error)
	// Save a key, value to badger. If a key is the same as an existing
	// key that has already been saved then the new value will overwrite the old.
	Set(Key, T) error
}

func NewModel

func NewModel() Model

New instantiates a new repository. A call to Open is required before use.

type Rpc

func NewRPC

func NewRPC(logger chassis.Logger, controller Controller) Rpc

type SetResponse

type SetResponse struct {
	Error error
	Data  interface{}
}

type T

type T = *anypb.Any

T is a type alias for the `anypb.Any` struct so that additional methods can be added to the message type.

Jump to

Keyboard shortcuts

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