kvproto

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2017 License: Apache-2.0 Imports: 3 Imported by: 79

Documentation

Overview

Package kvproto provides a wrapper that simplifies the storing and retrieving of proto-modelled data into/from a key-value data store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWatchResp

func NewWatchResp(serializer keyval.Serializer, resp keyval.BytesWatchResp) keyval.ProtoWatchResp

NewWatchResp initialize proto watch response from byte WatchResponse

Types

type ProtoWrapper

type ProtoWrapper struct {
	// contains filtered or unexported fields
}

ProtoWrapper is a decorator which allows to read/write proto file modelled data. It marshals/unmarshals go structures to slice off bytes and vice versa behind the scenes.

func NewProtoWrapper

func NewProtoWrapper(db keyval.CoreBrokerWatcher) *ProtoWrapper

NewProtoWrapper initializes proto decorator. The default serializer is used - SerializerProto.

func NewProtoWrapperWithSerializer

func NewProtoWrapperWithSerializer(db keyval.CoreBrokerWatcher, serializer keyval.Serializer) *ProtoWrapper

NewProtoWrapperWithSerializer initializes proto decorator with the specified serializer.

func (*ProtoWrapper) Close

func (db *ProtoWrapper) Close() error

Close closes underlying connection to etcd. Beware: if the connection is shared among multiple instances this might unintentionally cancel the connection.

func (*ProtoWrapper) Delete

func (db *ProtoWrapper) Delete(key string, opts ...datasync.DelOption) (existed bool, err error)

Delete removes from datastore key-value items stored under key.

func (*ProtoWrapper) GetValue

func (db *ProtoWrapper) GetValue(key string, reqObj proto.Message) (found bool, revision int64, err error)

GetValue retrieves one key-value item from the datastore. The item is identified by the provided key.

If the item was found, its value is unmarshaled and placed in the `reqObj` message buffer and the function returns found=true. If the object was not found, the function returns found=false. Function returns revision=revision of the latest modification If an error was encountered, the function returns an error.

func (*ProtoWrapper) ListKeys

func (db *ProtoWrapper) ListKeys(prefix string) (keyval.ProtoKeyIterator, error)

ListKeys is similar to the ListValues the difference is that values are not fetched

func (*ProtoWrapper) ListValues

func (db *ProtoWrapper) ListValues(key string) (keyval.ProtoKeyValIterator, error)

ListValues retrieves an iterator for elements stored under the provided key.

func (*ProtoWrapper) NewBroker

func (db *ProtoWrapper) NewBroker(prefix string) keyval.ProtoBroker

NewBroker creates a new instance of the proxy that shares the underlying connection and allows to read/edit key-value pairs.

func (*ProtoWrapper) NewTxn

func (db *ProtoWrapper) NewTxn() keyval.ProtoTxn

NewTxn creates a new Data Broker transaction. A transaction can holds multiple operations that are all committed to the data store together. After a transaction has been created, one or more operations (put or delete) can be added to the transaction before it is committed.

func (*ProtoWrapper) NewWatcher

func (db *ProtoWrapper) NewWatcher(prefix string) keyval.ProtoWatcher

NewWatcher creates a new instance of the proxy that shares the underlying connection and allows to subscribe for watching of the changes.

func (*ProtoWrapper) Put

func (db *ProtoWrapper) Put(key string, value proto.Message, opts ...datasync.PutOption) error

Put writes the provided key-value item into the data store.

Returns an error if the item could not be written, ok otherwise.

func (*ProtoWrapper) Watch

func (db *ProtoWrapper) Watch(resp func(keyval.ProtoWatchResp), keys ...string) error

Watch subscribes for changes in datastore associated with the key. respChannel is used for delivery watch events

Jump to

Keyboard shortcuts

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