kvstore

package
v0.0.0-...-6637ac4 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2019 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsulKVStore

type ConsulKVStore struct {
	KV *consulapi.KV
}

ConsulKVStore is an implementation of KVStore using Consul.

func NewConsulKVStore

func NewConsulKVStore(u *url.URL) (*ConsulKVStore, error)

NewConsulKVStore creates a new instance of the ConsulKVStore

func (*ConsulKVStore) Flush

func (kvs *ConsulKVStore) Flush() error

Flush is a no-op for consul backed KVStores

func (*ConsulKVStore) Get

func (kvs *ConsulKVStore) Get(key string) ([]byte, error)

Get returns the value, if any, stored under the given key. A nil value is returned if not present in the KVS

func (*ConsulKVStore) List

func (kvs *ConsulKVStore) List(key string) ([]*KVPair, error)

List returns a list of the objects stored under the given key. Nil is returned if nothing is present for the given key

func (*ConsulKVStore) Put

func (kvs *ConsulKVStore) Put(key string, value []byte) error

Put stores a value using the given key in consul

type HashKVStore

type HashKVStore struct {
	Store map[string][]byte
	// contains filtered or unexported fields
}

HashKVStore implements the KVStore interface using a hashmap

func NewHashKVStore

func NewHashKVStore(backingFile string) (*HashKVStore, error)

NewHashKVStore creates a new HashKVStore

func (*HashKVStore) ClearFaults

func (hkvs *HashKVStore) ClearFaults()

ClearFaults resets store to non-fault state

func (*HashKVStore) DumpToFile

func (hkvs *HashKVStore) DumpToFile() error

DumpToFile writes the content of the kv store to the backing file configured for the store.

func (*HashKVStore) Flush

func (hkvs *HashKVStore) Flush() error

Flush writes the KVStore in memory representation to disk.

func (*HashKVStore) Get

func (hkvs *HashKVStore) Get(key string) ([]byte, error)

Get returns the value (if any) under the given key

func (*HashKVStore) InjectFaults

func (hkvs *HashKVStore) InjectFaults()

InjectFaults forces Gets and Puts to return errors

func (*HashKVStore) List

func (hkvs *HashKVStore) List(key string) ([]*KVPair, error)

List returns all the values (if any) stored under the given key

func (*HashKVStore) LoadFromFile

func (hkvs *HashKVStore) LoadFromFile() error

LoadFromFile loads the flushed KVStore representation from file into memory

func (*HashKVStore) Put

func (hkvs *HashKVStore) Put(key string, value []byte) error

Put stores a value under the given key

type KVPair

type KVPair struct {
	Key   string
	Value []byte
}

KVPair represents a key value pair as used by the KVStore interface

type KVStore

type KVStore interface {
	Put(string, []byte) error
	Get(string) ([]byte, error)
	List(string) ([]*KVPair, error)
	Flush() error
}

KVStore is implemented by all key value store providers

func NewKVStore

func NewKVStore(envURL string) (KVStore, error)

NewKVStore instantiates a KV store implementation based on the url scheme associated with the given url

Jump to

Keyboard shortcuts

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