func getEtcdClient(etcdURI string) etcdclient.EtcdClient { etcdClient, err := etcdclient.Dial(etcdURI) if err != nil { log.Panicln("Error with etcdclient.New", err.Error()) } return etcdClient }
// Del deletes a key from etcd func Del(uri, key string) error { client, err := etcdclient.Dial(uri) if err != nil { return err } return client.Del(key) }
// UpdateDirWithTTL updates the ttl on the dir func UpdateDirWithTTL(uri, key string, ttlSeconds int) error { client, err := etcdclient.Dial(uri) if err != nil { return err } ttl := time.Duration(ttlSeconds) * time.Second return client.UpdateDirWithTTL(key, ttl) }
// Set sets a key on etcd, but only if its // different func Set(uri, key, value string) error { client, err := etcdclient.Dial(uri) if err != nil { return err } oldValue, err := client.Get(key) if err != nil { return err } if oldValue == value { return nil } return client.Set(key, value) }