Documentation
¶
Overview ¶
An abstraction layer for accessing data in etcd
Index ¶
- type CfgUtilPushStats
- type ClusterStats
- type Dal
- func (d *Dal) ClearCheckReference(memberID, keyName string) error
- func (d *Dal) ClearCheckReferences(memberID string) error
- func (d *Dal) CreateCheckReference(memberID, keyName string) error
- func (d *Dal) CreateDirectorState(data string) error
- func (d *Dal) Delete(key string, recursive bool) error
- func (d *Dal) FetchAlerterConfig(alertKey string) (string, error)
- func (d *Dal) FetchAllMemberRefs() (map[string]string, []string, error)
- func (d *Dal) FetchCheckStats() (map[string]*MemberStat, error)
- func (d *Dal) FetchEvents(types []string) ([]byte, error)
- func (d *Dal) FetchState() ([]byte, error)
- func (d *Dal) FetchStateWithTags(tags []string) ([]byte, error)
- func (d *Dal) Get(key string, getOptions *GetOptions) (map[string]string, error)
- func (d *Dal) GetCheckKeys() ([]string, error)
- func (d *Dal) GetCheckKeysWithMemberTag() (map[string]string, error)
- func (d *Dal) GetCheckMemberTag(checkKey string) (string, error)
- func (d *Dal) GetClusterMemberTags(memberID string) ([]string, error)
- func (d *Dal) GetClusterMembers() ([]string, error)
- func (d *Dal) GetClusterMembersWithTags() (map[string][]string, error)
- func (d *Dal) GetClusterStats() (*ClusterStats, error)
- func (d *Dal) IsKeyNotFound(err error) bool
- func (d *Dal) KeyExists(key string) (bool, bool, error)
- func (d *Dal) NewWatcher(key string, recursive bool) client.Watcher
- func (d *Dal) NewWatcherForOverwatch(key string, recursive bool) (client.Watcher, error)
- func (d *Dal) PushConfigs(configType string, configs map[string][]byte) (int, int, error)
- func (d *Dal) PushFullConfigs(fullConfigs *FullConfigs) (*CfgUtilPushStats, []string)
- func (d *Dal) Refresh(key string, ttl int) error
- func (d *Dal) Set(key, value string, opt *SetOptions) error
- func (d *Dal) UpdateCheckState(state bool, checkName string) error
- func (d *Dal) UpdateDirectorState(data, prevValue string, force bool) error
- type FullConfigs
- type GetOptions
- type IDal
- type MemberStat
- type SetOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CfgUtilPushStats ¶
type ClusterStats ¶
type ClusterStats struct {
Members map[string]*json.RawMessage
Director *json.RawMessage
}
type Dal ¶
type Dal struct {
Client client.Client
ClientConf client.Config
KeysAPI client.KeysAPI
Members []string
Prefix string
Replace bool
Dryrun bool
Nosync bool
Log log.FieldLogger
}
func (*Dal) ClearCheckReference ¶
Remove check reference for a given memberID + checkName
func (*Dal) ClearCheckReferences ¶
Remove all key refs under individual member config dir
func (*Dal) CreateCheckReference ¶
Create a check reference for a specific member under /cluster/members/*/config/*; check ref key is base64 encodded, value is set to the keyName
func (*Dal) CreateDirectorState ¶
Create director state entry (expecting director state key to not exist)
func (*Dal) FetchAlerterConfig ¶
Fetch a specific alerter config by its key name
func (*Dal) FetchAllMemberRefs ¶
Recursively fetch '/cluster/members/*/config/*', construct and return dataset that has 'map[check_key]memberID' structure
TODO: This is not great; should utilize caching at some point
func (*Dal) FetchCheckStats ¶
func (d *Dal) FetchCheckStats() (map[string]*MemberStat, error)
Fetch how many checks each cluster member has
func (*Dal) FetchEvents ¶
Fetch event data that matches at least one type specified in 'types'; if 'types' is empty, do not perform any filtering.
func (*Dal) FetchState ¶
Wrapper for fetching state information
func (*Dal) FetchStateWithTags ¶
Wrapper for fetching state information that is tagged with `tags`
Note: To avoid having to import the MonitorConfig struct, we will inspect it
manually via assertions and reflect.
func (*Dal) Get ¶
Get wrapper; either returns the key contents or error; accepts *GetOptions for specifying whether the method should recurse and/or use the default prefix.
By default, passing a nil for Options will NOT recurse and use the default prefix of `d.Prefix`. Passing in a `GetOptions{NoPrefix: true}` will cause GET to not use ANY prefix (assuming key name includes full path).
Returns a map[keyname]value; if dir is empty, return an empty map.
func (*Dal) GetCheckKeys ¶
Get a slice of all check keys in etcd (under /monitor/*)
func (*Dal) GetCheckKeysWithMemberTag ¶
Return check keys along with tags (if any); map k = check key name, v = member tag (if any)
func (*Dal) GetClusterMemberTags ¶
Get tags for a single cluster member
func (*Dal) GetClusterMembers ¶
Get slice of all member id's under /cluster/members/*
func (*Dal) GetClusterMembersWithTags ¶
Keys == member id, value == slice of tags
func (*Dal) GetClusterStats ¶
func (d *Dal) GetClusterStats() (*ClusterStats, error)
func (*Dal) IsKeyNotFound ¶
wrapper for etcd client's KeyNotFound error
func (*Dal) NewWatcherForOverwatch ¶
Same as NewWatcher, except we generate a fresh etcd client
func (*Dal) PushConfigs ¶
Wrapper for comparing existing value in etcd + (potentially) pushing value to etcd. If d.Replace is set, value in etcd will be replaced even if it's found to match
func (*Dal) PushFullConfigs ¶
func (d *Dal) PushFullConfigs(fullConfigs *FullConfigs) (*CfgUtilPushStats, []string)
Wrapper for pushing monitor and alerter configs + optionally syncing data
type FullConfigs ¶
type GetOptions ¶
type IDal ¶
type IDal interface {
Get(string, *GetOptions) (map[string]string, error)
Set(string, string, *SetOptions) error
Delete(string, bool) error
Refresh(string, int) error
KeyExists(string) (bool, bool, error)
IsKeyNotFound(error) bool
CreateDirectorState(string) error
UpdateDirectorState(string, string, bool) error
NewWatcher(string, bool) client.Watcher
NewWatcherForOverwatch(string, bool) (client.Watcher, error)
GetClusterMembers() ([]string, error)
GetCheckKeys() ([]string, error)
GetCheckKeysWithMemberTag() (map[string]string, error)
CreateCheckReference(string, string) error
ClearCheckReference(string, string) error
ClearCheckReferences(string) error
FetchAllMemberRefs() (map[string]string, []string, error)
FetchCheckStats() (map[string]*MemberStat, error)
FetchAlerterConfig(string) (string, error)
FetchState() ([]byte, error)
FetchStateWithTags([]string) ([]byte, error)
UpdateCheckState(bool, string) error
GetClusterStats() (*ClusterStats, error)
FetchEvents([]string) ([]byte, error)
GetClusterMembersWithTags() (map[string][]string, error)
GetClusterMemberTags(string) ([]string, error)
GetCheckMemberTag(string) (string, error)
PushConfigs(string, map[string][]byte) (int, int, error)
PushFullConfigs(*FullConfigs) (*CfgUtilPushStats, []string)
}
type MemberStat ¶
Helper struct for FetchCheckStats()
type SetOptions ¶
type SetOptions struct {
// If SetOptions.Dir=true then value is ignored.
Dir bool
TTLSec int
PrevExist string
// Create parents will recursively create parent directories as needed.
// The overall prefix defined as Dal.Prefix can not be set this way. This will create any
// parents up to but not including that prefix.
CreateParents bool
// To be used with create parents.
// If depth > 0 it will only create depth number of parents.
// If depth < 0 it will try to create as many parents as necessary.
// If depth == 0 it will not create any parents. This behaves the same as Set().
Depth int
}