Documentation
¶
Overview ¶
Package tools implements types which help work with etcd which depend on the api package. TODO: move this package to an etcd specific utility package.
Index ¶
- Constants
- Variables
- type EtcdClient
- type EtcdResponseWithError
- type FakeEtcdClient
- func (f *FakeEtcdClient) CompareAndSwap(key, value string, ttl uint64, prevValue string, prevIndex uint64) (*etcd.Response, error)
- func (f *FakeEtcdClient) Create(key, value string, ttl uint64) (*etcd.Response, error)
- func (f *FakeEtcdClient) Delete(key string, recursive bool) (*etcd.Response, error)
- func (f *FakeEtcdClient) ExpectNotFoundGet(key string)
- func (f *FakeEtcdClient) Get(key string, sort, recursive bool) (*etcd.Response, error)
- func (f *FakeEtcdClient) GetCluster() []string
- func (f *FakeEtcdClient) NewError(code int) *etcd.EtcdError
- func (f *FakeEtcdClient) Set(key, value string, ttl uint64) (*etcd.Response, error)
- func (f *FakeEtcdClient) SetError(err error)
- func (f *FakeEtcdClient) WaitForWatchCompletion()
- func (f *FakeEtcdClient) Watch(prefix string, waitIndex uint64, recursive bool, receiver chan *etcd.Response, ...) (*etcd.Response, error)
- type TestLogger
Constants ¶
View Source
const ( EtcdErrorCodeNotFound = 100 EtcdErrorCodeTestFailed = 101 EtcdErrorCodeNodeExist = 105 EtcdErrorCodeValueRequired = 200 )
Variables ¶
View Source
var ( EtcdErrorNotFound = &etcd.EtcdError{ErrorCode: EtcdErrorCodeNotFound} EtcdErrorTestFailed = &etcd.EtcdError{ErrorCode: EtcdErrorCodeTestFailed} EtcdErrorNodeExist = &etcd.EtcdError{ErrorCode: EtcdErrorCodeNodeExist} EtcdErrorValueRequired = &etcd.EtcdError{ErrorCode: EtcdErrorCodeValueRequired} )
Functions ¶
This section is empty.
Types ¶
type EtcdClient ¶
type EtcdClient interface { GetCluster() []string Get(key string, sort, recursive bool) (*etcd.Response, error) Set(key, value string, ttl uint64) (*etcd.Response, error) Create(key, value string, ttl uint64) (*etcd.Response, error) CompareAndSwap(key, value string, ttl uint64, prevValue string, prevIndex uint64) (*etcd.Response, error) Delete(key string, recursive bool) (*etcd.Response, error) // I'd like to use directional channels here (e.g. <-chan) but this interface mimics // the etcd client interface which doesn't, and it doesn't seem worth it to wrap the api. Watch(prefix string, waitIndex uint64, recursive bool, receiver chan *etcd.Response, stop chan bool) (*etcd.Response, error) }
EtcdClient is an injectable interface for testing.
type EtcdResponseWithError ¶
type EtcdResponseWithError struct { R *etcd.Response E error // if N is non-null, it will be assigned into the map after this response is used for an operation N *EtcdResponseWithError }
type FakeEtcdClient ¶
type FakeEtcdClient struct { Data map[string]EtcdResponseWithError DeletedKeys []string sync.Mutex Err error CasErr error Ix int TestIndex bool ChangeIndex uint64 LastSetTTL uint64 // Will avoid setting the expires header on objects to make comparison easier HideExpires bool Machines []string // Will become valid after Watch is called; tester may write to it. Tester may // also read from it to verify that it's closed after injecting an error. WatchResponse chan *etcd.Response WatchIndex uint64 // Write to this to prematurely stop a Watch that is running in a goroutine. WatchInjectError chan<- error WatchStop chan<- bool // If non-nil, will be returned immediately when Watch is called. WatchImmediateError error // contains filtered or unexported fields }
func NewFakeEtcdClient ¶
func NewFakeEtcdClient(t TestLogger) *FakeEtcdClient
func (*FakeEtcdClient) CompareAndSwap ¶
func (*FakeEtcdClient) ExpectNotFoundGet ¶
func (f *FakeEtcdClient) ExpectNotFoundGet(key string)
func (*FakeEtcdClient) GetCluster ¶ added in v0.5.2
func (f *FakeEtcdClient) GetCluster() []string
func (*FakeEtcdClient) NewError ¶ added in v0.12.0
func (f *FakeEtcdClient) NewError(code int) *etcd.EtcdError
func (*FakeEtcdClient) SetError ¶ added in v0.12.0
func (f *FakeEtcdClient) SetError(err error)
func (*FakeEtcdClient) WaitForWatchCompletion ¶
func (f *FakeEtcdClient) WaitForWatchCompletion()
type TestLogger ¶
type TestLogger interface { Fatalf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Logf(format string, args ...interface{}) }
TestLogger is a type passed to Test functions to support formatted test logs.
Click to show internal directories.
Click to hide internal directories.