svalue/value_test.go

27 lines
491 B
Go
Raw Normal View History

2019-01-23 19:18:17 +00:00
package svalue
import (
"context"
"time"
"go.etcd.io/etcd/clientv3"
)
type EtcdCurl struct {
Value
}
func (c *EtcdCurl) TakeValue() interface{} {
cli, err := clientv3.New(clientv3.Config{
Endpoints: []string{"http://10.10.0.1:2279"},
DialTimeout: 5 * time.Second,
})
resp, err := cli.Get(context.Background(), "phone", clientv3.WithPrefix())
must(err)
return string(resp.Kvs[0].Value)[0:20]
}
func (c *EtcdCurl) UpdateInterval() time.Duration {
return time.Second * 1
}