client: add KeysAPI.RGet

This commit is contained in:
Brian Waldon 2015-01-22 09:57:30 -08:00 committed by Yicheng Qin
parent 6d89e6217d
commit 8b3d05f661

View File

@ -65,6 +65,7 @@ type KeysAPI interface {
Update(ctx context.Context, key, value string) (*Response, error)
Get(ctx context.Context, key string) (*Response, error)
RGet(ctx context.Context, key string) (*Response, error)
Watch(key string, idx uint64) Watcher
RWatch(key string, idx uint64) Watcher
@ -154,6 +155,21 @@ func (k *httpKeysAPI) Get(ctx context.Context, key string) (*Response, error) {
return unmarshalHTTPResponse(resp.StatusCode, resp.Header, body)
}
func (k *httpKeysAPI) RGet(ctx context.Context, key string) (*Response, error) {
get := &getAction{
Prefix: k.prefix,
Key: key,
Recursive: true,
}
resp, body, err := k.client.Do(ctx, get)
if err != nil {
return nil, err
}
return unmarshalHTTPResponse(resp.StatusCode, resp.Header, body)
}
func (k *httpKeysAPI) Watch(key string, idx uint64) Watcher {
return &httpWatcher{
client: k.client,