update
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"log"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/consul/api"
|
||||
@@ -172,15 +173,20 @@ func populateEndpoints(ctx context.Context, clientConn resolver.ClientConn, inpu
|
||||
|
||||
sort.Sort(byAddressString(conns)) // Don't replace the same address list in the balancer
|
||||
|
||||
log.Printf("update conn: %s - %s", tgt.Service, conns)
|
||||
connInfo := make([]string, 0, len(conns))
|
||||
for _, conn := range conns {
|
||||
connInfo = append(connInfo, conn.Addr)
|
||||
}
|
||||
|
||||
log.Printf("update conn: %s num:%d [%s]", tgt.Service, len(connInfo), strings.Join(connInfo, ", "))
|
||||
|
||||
err := clientConn.UpdateState(resolver.State{Addresses: conns})
|
||||
if err != nil {
|
||||
grpclog.Errorf("[Consul resolver] Couldn't update client connection. error={%v}", err)
|
||||
grpclog.Errorf("[Consul resolver %s] Couldn't update client connection. error={%v}", tgt.Service, err)
|
||||
continue
|
||||
}
|
||||
case <-ctx.Done():
|
||||
grpclog.Info("[Consul resolver] Watch has been finished")
|
||||
grpclog.Infof("[Consul resolver %s] Watch has been finished", tgt.Service)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user