feat: service
continuous-integration/drone/push Build was killed

This commit is contained in:
2022-01-11 04:00:39 +08:00
parent 35119f2003
commit baa0eb8db2
22 changed files with 450 additions and 34 deletions
+5 -5
View File
@@ -11,8 +11,8 @@ import (
)
const (
EndPoints = "endpoints"
EndAddress = "etcd:2379"
EndPoints = "ENDPOINTS"
EndAddress = "etcd1:2379"
)
var (
@@ -40,11 +40,11 @@ func GetValue(key string) (string, error) {
}
kv := clientV3.NewKV(client)
defer client.Close()
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*3)
ctx, cancel := context.WithTimeout(context.TODO(), time.Minute*3)
defer cancel()
if getResp, err := kv.Get(ctx, key, clientV3.WithPrefix()); err == nil {
for _, v := range getResp.Kvs {
return string(v.Value), nil
if len(getResp.Kvs) > 0 {
return string(getResp.Kvs[0].Value), nil
}
} else {
return "", errors.New("etcd 连接超时")