kv

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2017 License: Apache-2.0 Imports: 23 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExists    = errors.New("Key exists")
	ErrNotExists = errors.New("Key and or Revision does not exists")
)

Functions

func New

func New(c Client, codec runtime.Codec, prefix string, transformer value.Transformer) storage.Interface

New returns an etcd3 implementation of storage.Interface.

Types

type Client

type Client interface {
	Get(ctx context.Context, key string) (*KeyValue, error)

	// Similar to get but looks for "like 'key%'"
	List(ctx context.Context, key string) ([]*KeyValue, error)

	// Should return ErrExists on conflict
	Create(ctx context.Context, key string, value []byte, ttl uint64) (*KeyValue, error)

	// Should return ErrNotExists on conflict
	Delete(ctx context.Context, key string) (*KeyValue, error)

	// Should return ErrNotExist
	DeleteVersion(ctx context.Context, key string, revision int64) error

	// Should return ErrNotExists, if key doesn't exist it should be created
	UpdateOrCreate(ctx context.Context, key string, value []byte, revision int64, ttl uint64) (*KeyValue, error)

	Watch(ctx context.Context, key string) ([]*KeyValue, WatchChan, error)
}

type Event

type Event struct {
	Create bool
	Delete bool
	Kv     *KeyValue
	PrevKv *KeyValue
}

type KeyValue

type KeyValue struct {
	Key      string
	Value    []byte
	Revision int64
}

type WatchChan

type WatchChan <-chan WatchResponse

type WatchResponse

type WatchResponse struct {
	Events []Event
	// contains filtered or unexported fields
}

func WatchResponseError

func WatchResponseError(err error) WatchResponse

func (*WatchResponse) Err

func (wr *WatchResponse) Err() error

Jump to

Keyboard shortcuts

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