Add missing gRPC functions
This commit is contained in:
@@ -40,17 +40,10 @@ func NewEtcdKVStore(cfg *viper.Viper) (EtcdKVStore, error) {
|
||||
}
|
||||
|
||||
func (s EtcdKVStore) Put(k string, v any) error {
|
||||
// var data bytes.Buffer // Stand-in for a network connection
|
||||
// enc := gob.NewEncoder(&data)
|
||||
// err := enc.Encode(v)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
data, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// _, err = s.Client.KV.Put(context.TODO(), k, data.String())
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
_, err = s.Client.KV.Put(ctx, k, string(data))
|
||||
cancel()
|
||||
@@ -66,17 +59,10 @@ func (s EtcdKVStore) PutWithTTL(k string, v any, duration time.Duration) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// var data bytes.Buffer // Stand-in for a network connection
|
||||
// enc := gob.NewEncoder(&data)
|
||||
// err = enc.Encode(v)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
data, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// _, err = s.Client.KV.Put(context.TODO(), k, data.String(), clientv3.WithLease(lease.ID))
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
_, err = s.Client.KV.Put(ctx, k, string(data), clientv3.WithLease(lease.ID))
|
||||
cancel()
|
||||
@@ -95,10 +81,6 @@ func (s EtcdKVStore) Get(k string) (any, error) {
|
||||
}
|
||||
for _, v := range resp.Kvs {
|
||||
var data any
|
||||
// var reader bytes.Buffer
|
||||
// reader.Write(v.Value)
|
||||
// enc := gob.NewDecoder(&reader)
|
||||
// err := enc.Decode(&data)
|
||||
err := json.Unmarshal([]byte(v.Value), &data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user