feat: 更改etcd默认地址
continuous-integration/drone/push Build is passing Details

master
icechen 2022-01-11 17:10:38 +08:00
parent d47feba0ba
commit 6dab1ffda3
2 changed files with 5 additions and 7 deletions

View File

@ -1,13 +1,11 @@
package model package model
import ( import (
"gorm.io/gorm" "git.icechen.cn/monorepo/backend/pkg/orm"
) )
var db *gorm.DB
func init() { func init() {
err := db.AutoMigrate(&UserInfo{}) err := orm.DB.AutoMigrate(&UserInfo{})
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@ -10,9 +10,9 @@ import (
"time" "time"
) )
const ( var (
EndPoints = "ENDPOINTS" EndPoints = "ENDPOINTS"
EndAddress = "etcd:2379" EndAddress = "etcd." + env.Namespace + ":2379"
) )
var ( var (
@ -40,7 +40,7 @@ func GetValue(key string) (string, error) {
} }
kv := clientV3.NewKV(client) kv := clientV3.NewKV(client)
defer client.Close() defer client.Close()
ctx, cancel := context.WithTimeout(context.TODO(), time.Minute*3) ctx, cancel := context.WithTimeout(context.TODO(), time.Second*3)
defer cancel() defer cancel()
if getResp, err := kv.Get(ctx, key, clientV3.WithPrefix()); err == nil { if getResp, err := kv.Get(ctx, key, clientV3.WithPrefix()); err == nil {
if len(getResp.Kvs) > 0 { if len(getResp.Kvs) > 0 {