mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
log
This commit is contained in:
parent
b2a9867297
commit
15aabb3859
@ -67,16 +67,16 @@ func RegisterEtcd(schema, etcdAddr, myHost string, myPort int, serviceName strin
|
||||
if err != nil {
|
||||
return fmt.Errorf("keepalive failed, errmsg:%v, lease id:%d", err, resp.ID)
|
||||
}
|
||||
log.Info("", "RegisterEtcd ok ")
|
||||
//log.Info("", "RegisterEtcd ok ")
|
||||
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case v, ok := <-kresp:
|
||||
case _, ok := <-kresp:
|
||||
if ok == true {
|
||||
log.Debug("", "KeepAlive kresp ok", v, schema, etcdAddr, myHost, myPort, serviceName, ttl)
|
||||
//log.Debug("", "KeepAlive kresp ok", v, schema, etcdAddr, myHost, myPort, serviceName, ttl)
|
||||
} else {
|
||||
log.Error("", "KeepAlive kresp failed", schema, etcdAddr, myHost, myPort, serviceName, ttl)
|
||||
//log.Error("", "KeepAlive kresp failed", schema, etcdAddr, myHost, myPort, serviceName, ttl)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package getcdv3
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"context"
|
||||
"fmt"
|
||||
"go.etcd.io/etcd/clientv3"
|
||||
@ -103,7 +102,7 @@ func (r *Resolver) Build(target resolver.Target, cc resolver.ClientConn, opts re
|
||||
if err == nil {
|
||||
var addrList []resolver.Address
|
||||
for i := range resp.Kvs {
|
||||
log.Debug("", "init addr: ", string(resp.Kvs[i].Value))
|
||||
//log.Debug("", "init addr: ", string(resp.Kvs[i].Value))
|
||||
addrList = append(addrList, resolver.Address{Addr: string(resp.Kvs[i].Value)})
|
||||
}
|
||||
r.cc.UpdateState(resolver.State{Addresses: addrList})
|
||||
@ -149,27 +148,27 @@ func (r *Resolver) watch(prefix string, addrList []resolver.Address) {
|
||||
if !exists(addrList, string(ev.Kv.Value)) {
|
||||
flag = 1
|
||||
addrList = append(addrList, resolver.Address{Addr: string(ev.Kv.Value)})
|
||||
log.Debug("", "after add, new list: ", addrList)
|
||||
//log.Debug("", "after add, new list: ", addrList)
|
||||
}
|
||||
case mvccpb.DELETE:
|
||||
log.Debug("remove addr key: ", string(ev.Kv.Key), "value:", string(ev.Kv.Value))
|
||||
//log.Debug("remove addr key: ", string(ev.Kv.Key), "value:", string(ev.Kv.Value))
|
||||
i := strings.LastIndexAny(string(ev.Kv.Key), "/")
|
||||
if i < 0 {
|
||||
return
|
||||
}
|
||||
t := string(ev.Kv.Key)[i+1:]
|
||||
log.Debug("remove addr key: ", string(ev.Kv.Key), "value:", string(ev.Kv.Value), "addr:", t)
|
||||
//log.Debug("remove addr key: ", string(ev.Kv.Key), "value:", string(ev.Kv.Value), "addr:", t)
|
||||
if s, ok := remove(addrList, t); ok {
|
||||
flag = 1
|
||||
addrList = s
|
||||
log.Debug("after remove, new list: ", addrList)
|
||||
//log.Debug("after remove, new list: ", addrList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if flag == 1 {
|
||||
r.cc.UpdateState(resolver.State{Addresses: addrList})
|
||||
log.Debug("update: ", addrList)
|
||||
//log.Debug("update: ", addrList)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -177,7 +176,7 @@ func (r *Resolver) watch(prefix string, addrList []resolver.Address) {
|
||||
func GetConn4Unique(schema, etcdaddr, servicename string) []*grpc.ClientConn {
|
||||
gEtcdCli, err := clientv3.New(clientv3.Config{Endpoints: strings.Split(etcdaddr, ",")})
|
||||
if err != nil {
|
||||
log.Error("clientv3.New failed", err.Error())
|
||||
//log.Error("clientv3.New failed", err.Error())
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -201,7 +200,7 @@ func GetConn4Unique(schema, etcdaddr, servicename string) []*grpc.ClientConn {
|
||||
}
|
||||
} else {
|
||||
gEtcdCli.Close()
|
||||
log.Error("gEtcdCli.Get failed", err.Error())
|
||||
//log.Error("gEtcdCli.Get failed", err.Error())
|
||||
return nil
|
||||
}
|
||||
gEtcdCli.Close()
|
||||
@ -237,7 +236,7 @@ func GetConnPool(schema, etcdaddr, servicename string) (*ClientConn, error) {
|
||||
ctx, _ := context.WithDeadline(context.Background(), time.Now().Add(1000*time.Millisecond))
|
||||
|
||||
c, err := p.Get(ctx)
|
||||
log.Info("", "Get ", err)
|
||||
//log.Info("", "Get ", err)
|
||||
return c, err
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user