clientv3: add KV constructor using pb.KVClient

This commit is contained in:
Anthony Romano 2016-06-24 13:43:39 -07:00
parent 54df540c2c
commit 17e0164f57

View File

@ -85,6 +85,10 @@ func NewKV(c *Client) KV {
return &kv{remote: pb.NewKVClient(c.conn)} return &kv{remote: pb.NewKVClient(c.conn)}
} }
func NewKVFromKVClient(remote pb.KVClient) KV {
return &kv{remote: remote}
}
func (kv *kv) Put(ctx context.Context, key, val string, opts ...OpOption) (*PutResponse, error) { func (kv *kv) Put(ctx context.Context, key, val string, opts ...OpOption) (*PutResponse, error) {
r, err := kv.Do(ctx, OpPut(key, val, opts...)) r, err := kv.Do(ctx, OpPut(key, val, opts...))
return r.put, toErr(ctx, err) return r.put, toErr(ctx, err)