Documentation ¶
Overview ¶
Copyright 2016 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func CreateEtcdDir(etcdClient etcd.KeysAPI, key string) error
- func EtcdDirExists(etcdClient etcd.KeysAPI, key string) (bool, error)
- func GetEtcdClient(peers []string) (etcd.KeysAPI, error)
- func GetEtcdClientFromEnv() (etcd.KeysAPI, error)
- func GetEtcdCode(err error) (int, bool)
- func GetEtcdPeers() ([]string, error)
- func GetEtcdValues(etcdClient etcd.KeysAPI, keys map[string]string) (values map[string]string, err error)
- func GetLeafKeyPath(key string) string
- func GetParentKeyPath(key string) string
- func IsEtcdCompareFailed(err error) bool
- func IsEtcdDirAlreadyExists(err error) bool
- func IsEtcdKeyNotFound(err error) bool
- func IsEtcdKeyReset(err error) bool
- func IsEtcdNodeExist(err error) bool
- func LoadPersistedNodeID(dataDir string) (string, error)
- func MockEtcdValueResponse(key string, value string, index uint64) *etcd.Response
- func StoreEtcdProperties(etcdClient etcd.KeysAPI, baseKey string, properties map[string]string) error
- func WatchEtcdKey(etcdClient etcd.KeysAPI, key string, index *uint64, timeout int) (string, bool, error)
- func WriteFile(filePath string, contentBuffer bytes.Buffer) error
- type MockEtcdClient
- func (r *MockEtcdClient) Create(ctx context.Context, key, value string) (*etcd.Response, error)
- func (r *MockEtcdClient) CreateDir(key string)
- func (r *MockEtcdClient) CreateDirs(key string, children *Set)
- func (r *MockEtcdClient) CreateInOrder(ctx context.Context, dir, value string, opts *etcd.CreateInOrderOptions) (*etcd.Response, error)
- func (r *MockEtcdClient) Delete(ctx context.Context, key string, opts *etcd.DeleteOptions) (*etcd.Response, error)
- func (r *MockEtcdClient) DeleteDir(key string)
- func (r *MockEtcdClient) DeleteValue(key string)
- func (r *MockEtcdClient) Dump()
- func (r *MockEtcdClient) Get(ctx context.Context, key string, opts *etcd.GetOptions) (*etcd.Response, error)
- func (r *MockEtcdClient) GetChildDirs(key string) *Set
- func (r *MockEtcdClient) GetValue(key string) string
- func (r *MockEtcdClient) MockEtcdDirResponse(key string, dir *MockEtcdDir, recursive bool, index uint64) *etcd.Response
- func (r *MockEtcdClient) ResetStore()
- func (r *MockEtcdClient) Set(ctx context.Context, key, value string, opts *etcd.SetOptions) (*etcd.Response, error)
- func (r *MockEtcdClient) SetValue(key, value string)
- func (r *MockEtcdClient) Update(ctx context.Context, key, value string) (*etcd.Response, error)
- func (r *MockEtcdClient) Watcher(key string, opts *etcd.WatcherOptions) etcd.Watcher
- type MockEtcdDir
- type MockWatcher
- type Set
- func (s *Set) Add(newValue string) bool
- func (s *Set) AddMultiple(values []string)
- func (s *Set) AddSet(other *Set)
- func (s *Set) Contains(value string) bool
- func (s *Set) Copy() *Set
- func (s *Set) Count() int
- func (s *Set) Equals(other *Set) bool
- func (s *Set) Iter() <-chan string
- func (s *Set) Remove(oldValue string) bool
- func (s *Set) Subtract(subset *Set)
- func (s *Set) ToSlice() []string
Constants ¶
const (
InfiniteTimeout = -1
)
Variables ¶
This section is empty.
Functions ¶
func CreateEtcdDir ¶
Create an etcd key. Ignores the error that it already exists.
func GetEtcdClientFromEnv ¶
func GetEtcdCode ¶
Converts the error to an etcd error code if possible. Returns the code and true if successfully parsed.
func GetEtcdPeers ¶
func GetEtcdValues ¶
func GetEtcdValues(etcdClient etcd.KeysAPI, keys map[string]string) (values map[string]string, err error)
Get all the values for the specified etcd keys, returned as a map of key names to values.
func GetLeafKeyPath ¶
func GetParentKeyPath ¶
func IsEtcdCompareFailed ¶
func IsEtcdDirAlreadyExists ¶
func IsEtcdKeyNotFound ¶
Check the error to see if it indicates an etcd was not found. True if a match, false otherwise.
func IsEtcdKeyReset ¶
Check if the error indicates the etcd key was reset
func IsEtcdNodeExist ¶
Check the error to see if it indicates an etcd key already exists. True if so, false otherwise.
func LoadPersistedNodeID ¶ added in v0.1.1
To ensure a constant node ID between runs, the id will be persisted in the data directory.
func MockEtcdValueResponse ¶
func StoreEtcdProperties ¶
func StoreEtcdProperties(etcdClient etcd.KeysAPI, baseKey string, properties map[string]string) error
Store each of the properties in etcd
Types ¶
type MockEtcdClient ¶
type MockEtcdClient struct { MockSet func(ctx context.Context, key, value string, opts *etcd.SetOptions) (*etcd.Response, error) MockGet func(ctx context.Context, key string, opts *etcd.GetOptions) (*etcd.Response, error) MockDelete func(ctx context.Context, key string, opts *etcd.DeleteOptions) (*etcd.Response, error) MockWatcher func(key string, opts *etcd.WatcherOptions) etcd.Watcher WatcherResponses map[string]string // contains filtered or unexported fields }
************************************************************************************************ KeysAPI interface mock implementation ************************************************************************************************
func NewMockEtcdClient ¶
func NewMockEtcdClient() *MockEtcdClient
func (*MockEtcdClient) CreateDir ¶
func (r *MockEtcdClient) CreateDir(key string)
Create a key and its parents as needed
func (*MockEtcdClient) CreateDirs ¶
func (r *MockEtcdClient) CreateDirs(key string, children *Set)
func (*MockEtcdClient) CreateInOrder ¶
func (r *MockEtcdClient) CreateInOrder(ctx context.Context, dir, value string, opts *etcd.CreateInOrderOptions) (*etcd.Response, error)
func (*MockEtcdClient) Delete ¶
func (r *MockEtcdClient) Delete(ctx context.Context, key string, opts *etcd.DeleteOptions) (*etcd.Response, error)
func (*MockEtcdClient) DeleteDir ¶
func (r *MockEtcdClient) DeleteDir(key string)
Delete a key and its children
func (*MockEtcdClient) DeleteValue ¶
func (r *MockEtcdClient) DeleteValue(key string)
Delete a value
func (*MockEtcdClient) Dump ¶
func (r *MockEtcdClient) Dump()
func (*MockEtcdClient) Get ¶
func (r *MockEtcdClient) Get(ctx context.Context, key string, opts *etcd.GetOptions) (*etcd.Response, error)
Get an etcd value. Defaults to an in-memory response to values that have been set for this client.
func (*MockEtcdClient) GetChildDirs ¶
func (r *MockEtcdClient) GetChildDirs(key string) *Set
Get the child directories of the key
func (*MockEtcdClient) GetValue ¶
func (r *MockEtcdClient) GetValue(key string) string
Get a value. If the key was not found, returns the empty string. To distinguish between an empty value and a key not found, call Get()
func (*MockEtcdClient) MockEtcdDirResponse ¶
func (r *MockEtcdClient) MockEtcdDirResponse(key string, dir *MockEtcdDir, recursive bool, index uint64) *etcd.Response
************************************************************************************************ Helpers to create etcd mocked responses ************************************************************************************************
func (*MockEtcdClient) ResetStore ¶
func (r *MockEtcdClient) ResetStore()
Reset the test value and directory store
func (*MockEtcdClient) Set ¶
func (r *MockEtcdClient) Set(ctx context.Context, key, value string, opts *etcd.SetOptions) (*etcd.Response, error)
Set an etcd value. Defaults to an in-memory store.
func (*MockEtcdClient) Watcher ¶
func (r *MockEtcdClient) Watcher(key string, opts *etcd.WatcherOptions) etcd.Watcher
type MockEtcdDir ¶
type MockEtcdDir struct { Path string Dirs map[string]*MockEtcdDir Values map[string]string }
type MockWatcher ¶
************************************************************************************************ Watcher interface Mock implementation ************************************************************************************************
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
func SetDifference ¶
find items in the left slice that are not in the right slice
func (*Set) Add ¶
Add a value to the set. Returns true if the value was added, false if it already exists.
func (*Set) AddMultiple ¶
Add multiple items more efficiently