Commit b0c130c5 authored by ale's avatar ale

use CreateDir to initialize presence directory

parent 6855abb0
......@@ -200,7 +200,7 @@ func (s *FakeEtcdClient) Set(key, value string, ttl uint64) (*etcd.Response, err
return s.trigger("set", key), nil
}
func (s *FakeEtcdClient) SetDir(key string, ttl uint64) (*etcd.Response, error) {
func (s *FakeEtcdClient) CreateDir(key string, ttl uint64) (*etcd.Response, error) {
// TODO. There are no directories.
return &etcd.Response{}, nil
}
......
package presence
import (
"fmt"
"log"
"time"
......@@ -12,10 +11,10 @@ import (
type EtcdClient interface {
AddChild(key string, value string, ttl uint64) (*etcd.Response, error)
Create(key string, value string, ttl uint64) (*etcd.Response, error)
CreateDir(key string, ttl uint64) (*etcd.Response, error)
Update(key string, value string, ttl uint64) (*etcd.Response, error)
Delete(key string, recursive bool) (*etcd.Response, error)
Get(key string, sort, recursive bool) (*etcd.Response, error)
SetDir(key string, ttl uint64) (*etcd.Response, error)
}
// A Client can read the list of active nodes written by Presence workers.
......@@ -77,10 +76,8 @@ func (p *Presence) Stop() {
// Start the presence worker.
func (p *Presence) Start() error {
// Create the presence directory if it does not exist.
if _, err := p.client.SetDir(p.path, 0); err != nil {
return fmt.Errorf("could not create presence directory: %v", err)
}
// Create the presence directory if it does not exist. Ignore errors.
p.client.CreateDir(p.path, 0)
go p.run()
return nil
......
......@@ -90,11 +90,11 @@ func NewEtcdClient(strongReads bool) EtcdClient {
type EtcdClient interface {
AddChild(string, string, uint64) (*etcd.Response, error)
Create(string, string, uint64) (*etcd.Response, error)
CreateDir(string, uint64) (*etcd.Response, error)
CompareAndSwap(string, string, uint64, string, uint64) (*etcd.Response, error)
Delete(string, bool) (*etcd.Response, error)
Get(string, bool, bool) (*etcd.Response, error)
Set(string, string, uint64) (*etcd.Response, error)
SetDir(string, uint64) (*etcd.Response, error)
Update(string, string, uint64) (*etcd.Response, error)
Watch(string, uint64, bool, chan *etcd.Response, chan bool) (*etcd.Response, error)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment