gapi, etcd: Define and implement a string sharing API for the World

This adds a new set of methods to the World API (for sharing data
throughout the cluster) and adds an etcd backed implementation.
This commit is contained in:
James Shubin
2017-03-03 16:26:42 -05:00
parent 1488e5ec4d
commit 203d866643
3 changed files with 139 additions and 0 deletions

View File

@@ -41,3 +41,24 @@ func (obj *World) ResCollect(hostnameFilter, kindFilter []string) ([]resources.R
// enforce that here if the underlying API supported it... Add this?
return GetResources(obj.EmbdEtcd, hostnameFilter, kindFilter)
}
// SetWatch returns a channel which spits out events on possible string changes.
func (obj *World) StrWatch(namespace string) chan error {
return WatchStr(obj.EmbdEtcd, namespace)
}
// StrGet returns a map of hostnames to values in the given namespace.
func (obj *World) StrGet(namespace string) (map[string]string, error) {
return GetStr(obj.EmbdEtcd, []string{}, namespace)
}
// StrSet sets the namespace value to a particular string under the identity of
// its own hostname.
func (obj *World) StrSet(namespace, value string) error {
return SetStr(obj.EmbdEtcd, obj.Hostname, namespace, &value)
}
// StrDel deletes the value in a particular namespace.
func (obj *World) StrDel(namespace string) error {
return SetStr(obj.EmbdEtcd, obj.Hostname, namespace, nil)
}