27 lines
491 B
Go
27 lines
491 B
Go
|
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
|
||
|
}
|