Ejemplo n.º 1
0
func get(pathNodes []string, key string) (string, error) {
	path := util.MakePath(append(pathNodes, key))
	response, err := client.Get(path, true, true)
	var value string
	if response != nil {
		value = response.Node.Value
	}
	return value, err
}
Ejemplo n.º 2
0
/**
 * Creates or Updates a key/value pair depending on whether _override_ is false
 * or true, on a path, with a certain time-to-live.
 */
func writeKey(pathNodes []string, key string, value string, ttl uint64, override bool) error {
	var err error = nil
	path := util.MakePath(append(pathNodes, key))
	if override {
		_, err = client.Set(path, value, ttl)
	} else {
		_, err = client.Create(path, value, ttl)
	}
	return err
}
Ejemplo n.º 3
0
/**
 * Creates or Updates a directory depending on whether _override_ is false
 * or true, on a path, with a certain time-to-live.
 */
func writeDir(pathNodes []string, dir string, ttl uint64, override bool) error {
	var err error = nil
	path := util.MakePath(append(pathNodes, dir))
	if override {
		_, err = client.UpdateDir(path, ttl)
	} else {
		_, err = client.CreateDir(path, ttl)
	}
	return err
}
Ejemplo n.º 4
0
func remove(pathNodes []string, key string) error {
	path := util.MakePath(append(pathNodes, key))
	_, err := client.Delete(path, true)
	return err
}