kv

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2019 License: Apache-2.0 Imports: 5 Imported by: 79

Documentation

Overview

Package kv is a generated GoMock package.

Index

Constants

View Source
const (
	// UninitializedVersion is the version of an uninitialized kv value.
	UninitializedVersion = 0
)

Variables

View Source
var (
	// ErrVersionMismatch is returned when attempting a CheckAndSet and the
	// key is not at the provided version
	ErrVersionMismatch = errors.New("key is not at the specified version")

	// ErrAlreadyExists is returned when attempting a SetIfEmpty and the key
	// already has a value
	ErrAlreadyExists = errors.New("key already has a value")

	// ErrNotFound is returned when attempting a Get but no value is found for
	// the given key
	ErrNotFound = errors.New("key not found")

	// ErrUnknownTargetType is returned when an unknown TargetType is requested
	ErrUnknownTargetType = errors.New("unknown target type")

	// ErrUnknownCompareType is returned when an unknown CompareType is requested
	ErrUnknownCompareType = errors.New("unknown compare type")

	// ErrUnknownOpType is returned when an unknown OpType is requested
	ErrUnknownOpType = errors.New("unknown op type")

	// ErrConditionCheckFailed is returned when condition check failed
	ErrConditionCheckFailed = errors.New("condition check failed")
)

Functions

This section is empty.

Types

type CompareType

type CompareType string

CompareType is the type of the comparison in the condition

const (
	CompareEqual CompareType = "="
)

list of supported CompareType

func (CompareType) String

func (t CompareType) String() string

type Condition

type Condition interface {
	// TargetType returns the type of the TargetType
	TargetType() TargetType
	// SetTargetType sets the type of the TargetType
	SetTargetType(t TargetType) Condition

	// CompareType returns the type of the CompareType
	CompareType() CompareType
	// SetCompareType sets the type of the CompareType
	SetCompareType(t CompareType) Condition

	// Key returns the key in the condition
	Key() string
	// SetKey sets the key in the condition
	SetKey(key string) Condition

	// Value returns the value for comparison
	Value() interface{}
	// SetValue sets the value for comparison
	SetValue(value interface{}) Condition
}

Condition defines the prerequisite for a transaction

func NewCondition

func NewCondition() Condition

NewCondition returns a new Condition

type MockCondition

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

MockCondition is a mock of Condition interface

func NewMockCondition

func NewMockCondition(ctrl *gomock.Controller) *MockCondition

NewMockCondition creates a new mock instance

func (*MockCondition) CompareType

func (m *MockCondition) CompareType() CompareType

CompareType mocks base method

func (*MockCondition) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockCondition) Key

func (m *MockCondition) Key() string

Key mocks base method

func (*MockCondition) SetCompareType

func (m *MockCondition) SetCompareType(t CompareType) Condition

SetCompareType mocks base method

func (*MockCondition) SetKey

func (m *MockCondition) SetKey(key string) Condition

SetKey mocks base method

func (*MockCondition) SetTargetType

func (m *MockCondition) SetTargetType(t TargetType) Condition

SetTargetType mocks base method

func (*MockCondition) SetValue

func (m *MockCondition) SetValue(value interface{}) Condition

SetValue mocks base method

func (*MockCondition) TargetType

func (m *MockCondition) TargetType() TargetType

TargetType mocks base method

func (*MockCondition) Value

func (m *MockCondition) Value() interface{}

Value mocks base method

type MockConditionMockRecorder

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

MockConditionMockRecorder is the mock recorder for MockCondition

func (*MockConditionMockRecorder) CompareType

func (mr *MockConditionMockRecorder) CompareType() *gomock.Call

CompareType indicates an expected call of CompareType

func (*MockConditionMockRecorder) Key

Key indicates an expected call of Key

func (*MockConditionMockRecorder) SetCompareType

func (mr *MockConditionMockRecorder) SetCompareType(t interface{}) *gomock.Call

SetCompareType indicates an expected call of SetCompareType

func (*MockConditionMockRecorder) SetKey

func (mr *MockConditionMockRecorder) SetKey(key interface{}) *gomock.Call

SetKey indicates an expected call of SetKey

func (*MockConditionMockRecorder) SetTargetType

func (mr *MockConditionMockRecorder) SetTargetType(t interface{}) *gomock.Call

SetTargetType indicates an expected call of SetTargetType

func (*MockConditionMockRecorder) SetValue

func (mr *MockConditionMockRecorder) SetValue(value interface{}) *gomock.Call

SetValue indicates an expected call of SetValue

func (*MockConditionMockRecorder) TargetType

func (mr *MockConditionMockRecorder) TargetType() *gomock.Call

TargetType indicates an expected call of TargetType

func (*MockConditionMockRecorder) Value

func (mr *MockConditionMockRecorder) Value() *gomock.Call

Value indicates an expected call of Value

type MockOp

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

MockOp is a mock of Op interface

func NewMockOp

func NewMockOp(ctrl *gomock.Controller) *MockOp

NewMockOp creates a new mock instance

func (*MockOp) EXPECT

func (m *MockOp) EXPECT() *MockOpMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockOp) Key

func (m *MockOp) Key() string

Key mocks base method

func (*MockOp) SetKey

func (m *MockOp) SetKey(key string) Op

SetKey mocks base method

func (*MockOp) SetType

func (m *MockOp) SetType(ot OpType) Op

SetType mocks base method

func (*MockOp) Type

func (m *MockOp) Type() OpType

Type mocks base method

type MockOpMockRecorder

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

MockOpMockRecorder is the mock recorder for MockOp

func (*MockOpMockRecorder) Key

func (mr *MockOpMockRecorder) Key() *gomock.Call

Key indicates an expected call of Key

func (*MockOpMockRecorder) SetKey

func (mr *MockOpMockRecorder) SetKey(key interface{}) *gomock.Call

SetKey indicates an expected call of SetKey

func (*MockOpMockRecorder) SetType

func (mr *MockOpMockRecorder) SetType(ot interface{}) *gomock.Call

SetType indicates an expected call of SetType

func (*MockOpMockRecorder) Type

func (mr *MockOpMockRecorder) Type() *gomock.Call

Type indicates an expected call of Type

type MockOpResponse

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

MockOpResponse is a mock of OpResponse interface

func NewMockOpResponse

func NewMockOpResponse(ctrl *gomock.Controller) *MockOpResponse

NewMockOpResponse creates a new mock instance

func (*MockOpResponse) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockOpResponse) Key

func (m *MockOpResponse) Key() string

Key mocks base method

func (*MockOpResponse) SetKey

func (m *MockOpResponse) SetKey(key string) Op

SetKey mocks base method

func (*MockOpResponse) SetType

func (m *MockOpResponse) SetType(ot OpType) Op

SetType mocks base method

func (*MockOpResponse) SetValue

func (m *MockOpResponse) SetValue(v interface{}) OpResponse

SetValue mocks base method

func (*MockOpResponse) Type

func (m *MockOpResponse) Type() OpType

Type mocks base method

func (*MockOpResponse) Value

func (m *MockOpResponse) Value() interface{}

Value mocks base method

type MockOpResponseMockRecorder

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

MockOpResponseMockRecorder is the mock recorder for MockOpResponse

func (*MockOpResponseMockRecorder) Key

Key indicates an expected call of Key

func (*MockOpResponseMockRecorder) SetKey

func (mr *MockOpResponseMockRecorder) SetKey(key interface{}) *gomock.Call

SetKey indicates an expected call of SetKey

func (*MockOpResponseMockRecorder) SetType

func (mr *MockOpResponseMockRecorder) SetType(ot interface{}) *gomock.Call

SetType indicates an expected call of SetType

func (*MockOpResponseMockRecorder) SetValue

func (mr *MockOpResponseMockRecorder) SetValue(v interface{}) *gomock.Call

SetValue indicates an expected call of SetValue

func (*MockOpResponseMockRecorder) Type

Type indicates an expected call of Type

func (*MockOpResponseMockRecorder) Value

func (mr *MockOpResponseMockRecorder) Value() *gomock.Call

Value indicates an expected call of Value

type MockOverrideOptions

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

MockOverrideOptions is a mock of OverrideOptions interface

func NewMockOverrideOptions

func NewMockOverrideOptions(ctrl *gomock.Controller) *MockOverrideOptions

NewMockOverrideOptions creates a new mock instance

func (*MockOverrideOptions) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockOverrideOptions) Environment

func (m *MockOverrideOptions) Environment() string

Environment mocks base method

func (*MockOverrideOptions) Namespace

func (m *MockOverrideOptions) Namespace() string

Namespace mocks base method

func (*MockOverrideOptions) SetEnvironment

func (m *MockOverrideOptions) SetEnvironment(env string) OverrideOptions

SetEnvironment mocks base method

func (*MockOverrideOptions) SetNamespace

func (m *MockOverrideOptions) SetNamespace(namespace string) OverrideOptions

SetNamespace mocks base method

func (*MockOverrideOptions) SetZone

func (m *MockOverrideOptions) SetZone(value string) OverrideOptions

SetZone mocks base method

func (*MockOverrideOptions) Validate

func (m *MockOverrideOptions) Validate() error

Validate mocks base method

func (*MockOverrideOptions) Zone

func (m *MockOverrideOptions) Zone() string

Zone mocks base method

type MockOverrideOptionsMockRecorder

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

MockOverrideOptionsMockRecorder is the mock recorder for MockOverrideOptions

func (*MockOverrideOptionsMockRecorder) Environment

func (mr *MockOverrideOptionsMockRecorder) Environment() *gomock.Call

Environment indicates an expected call of Environment

func (*MockOverrideOptionsMockRecorder) Namespace

func (mr *MockOverrideOptionsMockRecorder) Namespace() *gomock.Call

Namespace indicates an expected call of Namespace

func (*MockOverrideOptionsMockRecorder) SetEnvironment

func (mr *MockOverrideOptionsMockRecorder) SetEnvironment(env interface{}) *gomock.Call

SetEnvironment indicates an expected call of SetEnvironment

func (*MockOverrideOptionsMockRecorder) SetNamespace

func (mr *MockOverrideOptionsMockRecorder) SetNamespace(namespace interface{}) *gomock.Call

SetNamespace indicates an expected call of SetNamespace

func (*MockOverrideOptionsMockRecorder) SetZone

func (mr *MockOverrideOptionsMockRecorder) SetZone(value interface{}) *gomock.Call

SetZone indicates an expected call of SetZone

func (*MockOverrideOptionsMockRecorder) Validate

Validate indicates an expected call of Validate

func (*MockOverrideOptionsMockRecorder) Zone

Zone indicates an expected call of Zone

type MockResponse

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

MockResponse is a mock of Response interface

func NewMockResponse

func NewMockResponse(ctrl *gomock.Controller) *MockResponse

NewMockResponse creates a new mock instance

func (*MockResponse) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockResponse) Responses

func (m *MockResponse) Responses() []OpResponse

Responses mocks base method

func (*MockResponse) SetResponses

func (m *MockResponse) SetResponses(oprs []OpResponse) Response

SetResponses mocks base method

type MockResponseMockRecorder

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

MockResponseMockRecorder is the mock recorder for MockResponse

func (*MockResponseMockRecorder) Responses

func (mr *MockResponseMockRecorder) Responses() *gomock.Call

Responses indicates an expected call of Responses

func (*MockResponseMockRecorder) SetResponses

func (mr *MockResponseMockRecorder) SetResponses(oprs interface{}) *gomock.Call

SetResponses indicates an expected call of SetResponses

type MockStore

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

MockStore is a mock of Store interface

func NewMockStore

func NewMockStore(ctrl *gomock.Controller) *MockStore

NewMockStore creates a new mock instance

func (*MockStore) CheckAndSet

func (m *MockStore) CheckAndSet(key string, version int, v proto.Message) (int, error)

CheckAndSet mocks base method

func (*MockStore) Delete

func (m *MockStore) Delete(key string) (Value, error)

Delete mocks base method

func (*MockStore) EXPECT

func (m *MockStore) EXPECT() *MockStoreMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockStore) Get

func (m *MockStore) Get(key string) (Value, error)

Get mocks base method

func (*MockStore) History

func (m *MockStore) History(key string, from, to int) ([]Value, error)

History mocks base method

func (*MockStore) Set

func (m *MockStore) Set(key string, v proto.Message) (int, error)

Set mocks base method

func (*MockStore) SetIfNotExists

func (m *MockStore) SetIfNotExists(key string, v proto.Message) (int, error)

SetIfNotExists mocks base method

func (*MockStore) Watch

func (m *MockStore) Watch(key string) (ValueWatch, error)

Watch mocks base method

type MockStoreMockRecorder

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

MockStoreMockRecorder is the mock recorder for MockStore

func (*MockStoreMockRecorder) CheckAndSet

func (mr *MockStoreMockRecorder) CheckAndSet(key, version, v interface{}) *gomock.Call

CheckAndSet indicates an expected call of CheckAndSet

func (*MockStoreMockRecorder) Delete

func (mr *MockStoreMockRecorder) Delete(key interface{}) *gomock.Call

Delete indicates an expected call of Delete

func (*MockStoreMockRecorder) Get

func (mr *MockStoreMockRecorder) Get(key interface{}) *gomock.Call

Get indicates an expected call of Get

func (*MockStoreMockRecorder) History

func (mr *MockStoreMockRecorder) History(key, from, to interface{}) *gomock.Call

History indicates an expected call of History

func (*MockStoreMockRecorder) Set

func (mr *MockStoreMockRecorder) Set(key, v interface{}) *gomock.Call

Set indicates an expected call of Set

func (*MockStoreMockRecorder) SetIfNotExists

func (mr *MockStoreMockRecorder) SetIfNotExists(key, v interface{}) *gomock.Call

SetIfNotExists indicates an expected call of SetIfNotExists

func (*MockStoreMockRecorder) Watch

func (mr *MockStoreMockRecorder) Watch(key interface{}) *gomock.Call

Watch indicates an expected call of Watch

type MockTxnStore

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

MockTxnStore is a mock of TxnStore interface

func NewMockTxnStore

func NewMockTxnStore(ctrl *gomock.Controller) *MockTxnStore

NewMockTxnStore creates a new mock instance

func (*MockTxnStore) CheckAndSet

func (m *MockTxnStore) CheckAndSet(key string, version int, v proto.Message) (int, error)

CheckAndSet mocks base method

func (*MockTxnStore) Commit

func (m *MockTxnStore) Commit(arg0 []Condition, arg1 []Op) (Response, error)

Commit mocks base method

func (*MockTxnStore) Delete

func (m *MockTxnStore) Delete(key string) (Value, error)

Delete mocks base method

func (*MockTxnStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockTxnStore) Get

func (m *MockTxnStore) Get(key string) (Value, error)

Get mocks base method

func (*MockTxnStore) History

func (m *MockTxnStore) History(key string, from, to int) ([]Value, error)

History mocks base method

func (*MockTxnStore) Set

func (m *MockTxnStore) Set(key string, v proto.Message) (int, error)

Set mocks base method

func (*MockTxnStore) SetIfNotExists

func (m *MockTxnStore) SetIfNotExists(key string, v proto.Message) (int, error)

SetIfNotExists mocks base method

func (*MockTxnStore) Watch

func (m *MockTxnStore) Watch(key string) (ValueWatch, error)

Watch mocks base method

type MockTxnStoreMockRecorder

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

MockTxnStoreMockRecorder is the mock recorder for MockTxnStore

func (*MockTxnStoreMockRecorder) CheckAndSet

func (mr *MockTxnStoreMockRecorder) CheckAndSet(key, version, v interface{}) *gomock.Call

CheckAndSet indicates an expected call of CheckAndSet

func (*MockTxnStoreMockRecorder) Commit

func (mr *MockTxnStoreMockRecorder) Commit(arg0, arg1 interface{}) *gomock.Call

Commit indicates an expected call of Commit

func (*MockTxnStoreMockRecorder) Delete

func (mr *MockTxnStoreMockRecorder) Delete(key interface{}) *gomock.Call

Delete indicates an expected call of Delete

func (*MockTxnStoreMockRecorder) Get

func (mr *MockTxnStoreMockRecorder) Get(key interface{}) *gomock.Call

Get indicates an expected call of Get

func (*MockTxnStoreMockRecorder) History

func (mr *MockTxnStoreMockRecorder) History(key, from, to interface{}) *gomock.Call

History indicates an expected call of History

func (*MockTxnStoreMockRecorder) Set

func (mr *MockTxnStoreMockRecorder) Set(key, v interface{}) *gomock.Call

Set indicates an expected call of Set

func (*MockTxnStoreMockRecorder) SetIfNotExists

func (mr *MockTxnStoreMockRecorder) SetIfNotExists(key, v interface{}) *gomock.Call

SetIfNotExists indicates an expected call of SetIfNotExists

func (*MockTxnStoreMockRecorder) Watch

func (mr *MockTxnStoreMockRecorder) Watch(key interface{}) *gomock.Call

Watch indicates an expected call of Watch

type MockValue

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

MockValue is a mock of Value interface

func NewMockValue

func NewMockValue(ctrl *gomock.Controller) *MockValue

NewMockValue creates a new mock instance

func (*MockValue) EXPECT

func (m *MockValue) EXPECT() *MockValueMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockValue) IsNewer

func (m *MockValue) IsNewer(other Value) bool

IsNewer mocks base method

func (*MockValue) Unmarshal

func (m *MockValue) Unmarshal(v proto.Message) error

Unmarshal mocks base method

func (*MockValue) Version

func (m *MockValue) Version() int

Version mocks base method

type MockValueMockRecorder

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

MockValueMockRecorder is the mock recorder for MockValue

func (*MockValueMockRecorder) IsNewer

func (mr *MockValueMockRecorder) IsNewer(other interface{}) *gomock.Call

IsNewer indicates an expected call of IsNewer

func (*MockValueMockRecorder) Unmarshal

func (mr *MockValueMockRecorder) Unmarshal(v interface{}) *gomock.Call

Unmarshal indicates an expected call of Unmarshal

func (*MockValueMockRecorder) Version

func (mr *MockValueMockRecorder) Version() *gomock.Call

Version indicates an expected call of Version

type MockValueWatch

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

MockValueWatch is a mock of ValueWatch interface

func NewMockValueWatch

func NewMockValueWatch(ctrl *gomock.Controller) *MockValueWatch

NewMockValueWatch creates a new mock instance

func (*MockValueWatch) C

func (m *MockValueWatch) C() <-chan struct{}

C mocks base method

func (*MockValueWatch) Close

func (m *MockValueWatch) Close()

Close mocks base method

func (*MockValueWatch) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockValueWatch) Get

func (m *MockValueWatch) Get() Value

Get mocks base method

type MockValueWatchMockRecorder

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

MockValueWatchMockRecorder is the mock recorder for MockValueWatch

func (*MockValueWatchMockRecorder) C

C indicates an expected call of C

func (*MockValueWatchMockRecorder) Close

func (mr *MockValueWatchMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close

func (*MockValueWatchMockRecorder) Get

Get indicates an expected call of Get

type MockValueWatchable

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

MockValueWatchable is a mock of ValueWatchable interface

func NewMockValueWatchable

func NewMockValueWatchable(ctrl *gomock.Controller) *MockValueWatchable

NewMockValueWatchable creates a new mock instance

func (*MockValueWatchable) Close

func (m *MockValueWatchable) Close()

Close mocks base method

func (*MockValueWatchable) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockValueWatchable) Get

func (m *MockValueWatchable) Get() Value

Get mocks base method

func (*MockValueWatchable) IsClosed

func (m *MockValueWatchable) IsClosed() bool

IsClosed mocks base method

func (*MockValueWatchable) NumWatches

func (m *MockValueWatchable) NumWatches() int

NumWatches mocks base method

func (*MockValueWatchable) Update

func (m *MockValueWatchable) Update(arg0 Value) error

Update mocks base method

func (*MockValueWatchable) Watch

func (m *MockValueWatchable) Watch() (Value, ValueWatch, error)

Watch mocks base method

type MockValueWatchableMockRecorder

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

MockValueWatchableMockRecorder is the mock recorder for MockValueWatchable

func (*MockValueWatchableMockRecorder) Close

Close indicates an expected call of Close

func (*MockValueWatchableMockRecorder) Get

Get indicates an expected call of Get

func (*MockValueWatchableMockRecorder) IsClosed

func (mr *MockValueWatchableMockRecorder) IsClosed() *gomock.Call

IsClosed indicates an expected call of IsClosed

func (*MockValueWatchableMockRecorder) NumWatches

func (mr *MockValueWatchableMockRecorder) NumWatches() *gomock.Call

NumWatches indicates an expected call of NumWatches

func (*MockValueWatchableMockRecorder) Update

func (mr *MockValueWatchableMockRecorder) Update(arg0 interface{}) *gomock.Call

Update indicates an expected call of Update

func (*MockValueWatchableMockRecorder) Watch

Watch indicates an expected call of Watch

type Op

type Op interface {
	// Type returns the type of the operation
	Type() OpType
	// SetType sets the type of the operation
	SetType(ot OpType) Op

	// Key returns the key used in the operation
	Key() string
	// SetKey sets the key in the operation
	SetKey(key string) Op
}

Op is the operation to be performed in a transaction

type OpResponse

type OpResponse interface {
	Op

	Value() interface{}
	SetValue(v interface{}) OpResponse
}

OpResponse is the response of a transaction operation

func NewOpResponse

func NewOpResponse(op Op) OpResponse

NewOpResponse creates a new OpResponse

type OpType

type OpType int

OpType is the type of the operation

const (
	OpSet OpType = iota
)

list of supported OpTypes

type OverrideConfiguration

type OverrideConfiguration struct {
	Zone        string `yaml:"zone"`
	Environment string `yaml:"environment"`
	Namespace   string `yaml:"namespace"`
}

OverrideConfiguration is the config for OverrideOptions.

func (OverrideConfiguration) NewOverrideOptions

func (cfg OverrideConfiguration) NewOverrideOptions() (OverrideOptions, error)

NewOverrideOptions creates a OverrideOptions.

type OverrideOptions

type OverrideOptions interface {
	// Zone returns the zone of the KV store.
	Zone() string

	// SetZone sets the zone of the KV store.
	SetZone(value string) OverrideOptions

	// Namespace returns the namespace of the KV store.
	Namespace() string

	// SetNamespace sets the namespace of the KV store.
	SetNamespace(namespace string) OverrideOptions

	// Environment returns the environment of the KV store.
	Environment() string

	// SetEnvironment sets the environment of the KV store.
	SetEnvironment(env string) OverrideOptions

	// Validate validates the Options.
	Validate() error
}

OverrideOptions provides a set of options to override the default configurations of a KV store.

func NewOverrideOptions

func NewOverrideOptions() OverrideOptions

NewOverrideOptions creates a new kv Options.

type Response

type Response interface {
	Responses() []OpResponse
	SetResponses(oprs []OpResponse) Response
}

Response captures the response of the transaction

func NewResponse

func NewResponse() Response

NewResponse creates a new transaction Response

type SetOp

type SetOp struct {
	Value proto.Message
	// contains filtered or unexported fields
}

SetOp is a Op with OpType Set

func NewSetOp

func NewSetOp(key string, value proto.Message) SetOp

NewSetOp returns a SetOp

func (SetOp) Key

func (r SetOp) Key() string

func (SetOp) SetKey

func (r SetOp) SetKey(key string) Op

func (SetOp) SetType

func (r SetOp) SetType(t OpType) Op

func (SetOp) Type

func (r SetOp) Type() OpType

type Store

type Store interface {
	// Get retrieves the value for the given key
	Get(key string) (Value, error)

	// Watch adds a watch for value updates for given key. This is a non-blocking
	// call - a notification will be sent to ValueWatch.C() once a value is
	// available
	Watch(key string) (ValueWatch, error)

	// Set stores the value for the given key
	Set(key string, v proto.Message) (int, error)

	// SetIfNotExists sets the value for the given key only if no value already
	// exists
	SetIfNotExists(key string, v proto.Message) (int, error)

	// CheckAndSet stores the value for the given key if the current version
	// matches the provided version
	CheckAndSet(key string, version int, v proto.Message) (int, error)

	// Delete deletes a key in the store and returns the last value before deletion
	Delete(key string) (Value, error)

	// History returns the value for a key in version range [from, to)
	History(key string, from, to int) ([]Value, error)
}

Store provides access to the configuration store

type TargetType

type TargetType int

TargetType is the type of the comparison target in the condition

const (
	TargetVersion TargetType = iota
)

list of supported TargetTypes

type TxnStore

type TxnStore interface {
	Store

	Commit([]Condition, []Op) (Response, error)
}

TxnStore supports transactions on top of Store interface

type Value

type Value interface {
	// Unmarshal retrieves the stored value
	Unmarshal(v proto.Message) error

	// Version returns the current version of the value
	Version() int

	// IsNewer returns if this Value is newer than the other Value
	IsNewer(other Value) bool
}

A Value provides access to a versioned value in the configuration store

type ValueWatch

type ValueWatch interface {
	// C returns the notification channel
	C() <-chan struct{}
	// Get returns the latest version of the value
	Get() Value
	// Close stops watching for value updates
	Close()
}

ValueWatch provides updates to a Value

type ValueWatchable

type ValueWatchable interface {
	// Get returns the latest Value
	Get() Value
	// Watch returns the Value and a ValueWatch that will be notified on updates
	Watch() (Value, ValueWatch, error)
	// NumWatches returns the number of watches on the Watchable
	NumWatches() int
	// Update sets the Value and notify Watches
	Update(Value) error
	// IsClosed returns true if the Watchable is closed
	IsClosed() bool
	// Close stops watching for value updates
	Close()
}

ValueWatchable can be watched for Value changes

func NewValueWatchable

func NewValueWatchable() ValueWatchable

NewValueWatchable creates a new ValueWatchable

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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