store

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorNoRecord = errors.New("no key found")

ErrorNoRecord ...

Functions

This section is empty.

Types

type EtcdConfig

type EtcdConfig struct {
	Endpoints []string
}

EtcdConfig defines etcd store configuration info

type Manager

type Manager interface {
	Close() error

	// General-purpose collection/key/value storage
	Put(ctx context.Context, collection string, key string, value []byte, ttlSeconds int64) error
	Delete(ctx context.Context, collection string, key string) error
	// Watch a collection for changes
	Watch(ctx context.Context, collection string) <-chan WatchResult
	// Watch a key for changes
	WatchKey(ctx context.Context, collection, key string) <-chan WatchResult

	Get(ctx context.Context, collection string, key string) ([]byte, error)
	Exists(ctx context.Context, collection string, key string) (bool, error)
	List(cctx context.Context, collection string, limit, page int64, newestFirst bool) ([]Result, int64, error)
}

Manager defines a general interface for managing objects

func NewETCDManager

func NewETCDManager(ctx context.Context, config EtcdConfig) (Manager, error)

NewETCDManager returns etcd store implementation

func NewETCDMockManager

func NewETCDMockManager() (Manager, error)

NewETCDMockManager returns a manager suitable for test environments.

func NewManager

func NewManager(ctx context.Context, config interface{}) (Manager, error)

NewManager creates a new KV manager based on the type of config file supplied.

type OperationType

type OperationType int32

OperationType is the type of operation performed on a record

const (
	// OperationTypePUT Represents PUT storage operations
	OperationTypePUT OperationType = 0
	// OperationTypeDELETE Represents DELETE storage operations
	OperationTypeDELETE OperationType = 1
)

type Result

type Result struct {
	Key   string
	Value []byte
}

Result represents a k/v result

type WatchResult

type WatchResult struct {
	Result Result
	Type   OperationType
	Err    error
}

WatchResult represents changes in a watched collection

Jump to

Keyboard shortcuts

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