easykv

package module
v1.2.11 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 2 Imported by: 2

README

Build Status Go Report Card MIT licensed

easyKV

easyKV is based on the backends of confd. easyKV provides a very simple interface to work with some key-value stores. The goal of easyKV is to abstract these 2 common operations for multiple backends:

  • recursively query the kv-store for key-value pairs.
  • watch a key-prefix for changes.

Interface

A storage backend in easyKV should implement (fully or partially) this interface:

type ReadWatcher interface {
	GetValues(keys []string) (map[string]string, error)
	WatchPrefix(ctx context.Context, prefix string, opts ...WatchOption) (uint64, error)
	Close()
}

Compatibility matrix

Calls Consul Etcdv2 Etcdv3 env file redis vault zookeeper nats kv
GetValues X X X X X X X X X
WatchPrefix X X X X X X
Close X X X X X X X X X

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWatchCanceled = errors.New("watcher error: watcher canceled")

ErrWatchCanceled is returned if the watcher is canceled.

View Source
var ErrWatchNotSupported = errors.New("this backend doesn't support watches - use polling instead")

ErrWatchNotSupported is returned if the backend has no watch support and the WatchPrefix method is called.

Functions

This section is empty.

Types

type ReadWatcher

type ReadWatcher interface {
	GetValues(keys []string) (map[string]string, error)
	WatchPrefix(ctx context.Context, prefix string, opts ...WatchOption) (uint64, error)
	Close()
}

A ReadWatcher - can get values and watch a prefix for changes

type WatchOption

type WatchOption func(*WatchOptions)

WatchOption configures the WatchPrefix operation

func WithKeys

func WithKeys(keys []string) WatchOption

WithKeys reduces the scope of keys that can trigger updates to keys (not an exact match)

func WithWaitIndex

func WithWaitIndex(waitIndex uint64) WatchOption

WithWaitIndex sets the WaitIndex of the watcher

type WatchOptions

type WatchOptions struct {
	WaitIndex uint64
	Keys      []string
}

WatchOptions represents options for watch operations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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