discovery: init commit

This commit is contained in:
Xiang Li
2014-09-21 11:26:59 -07:00
parent a4cca35e9d
commit 2b623cf0fa
5 changed files with 478 additions and 5 deletions

View File

@@ -16,8 +16,8 @@ var (
type Client interface {
Create(key, value string, ttl time.Duration) (*Response, error)
Get(key string) (*Response, error)
Watch(key string) Watcher
RecursiveWatch(key string) Watcher
Watch(key string, idx uint64) Watcher
RecursiveWatch(key string, idx uint64) Watcher
}
type Watcher interface {
@@ -30,7 +30,7 @@ type Response struct {
PrevNode *Node `json:"prevNode"`
}
type Nodes []Node
type Nodes []*Node
type Node struct {
Key string `json:"key"`
Value string `json:"value"`

View File

@@ -127,7 +127,7 @@ func (c *httpClient) do(ctx context.Context, act httpAction) (*http.Response, []
return resp, body, err
}
func (c *httpClient) Watch(key string, idx uint64) *httpWatcher {
func (c *httpClient) Watch(key string, idx uint64) Watcher {
return &httpWatcher{
httpClient: *c,
nextWait: waitAction{
@@ -138,7 +138,7 @@ func (c *httpClient) Watch(key string, idx uint64) *httpWatcher {
}
}
func (c *httpClient) RecursiveWatch(key string, idx uint64) *httpWatcher {
func (c *httpClient) RecursiveWatch(key string, idx uint64) Watcher {
return &httpWatcher{
httpClient: *c,
nextWait: waitAction{