1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-03-17 21:07:54 +02:00

Merge pull request #212 from bilibili/fix_naming

check nil instance
This commit is contained in:
Tony 2019-07-17 10:00:23 +08:00 committed by GitHub
commit 4023d6638a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -609,6 +609,10 @@ func (d *Discovery) polls(ctx context.Context) (apps map[string]*naming.Instance
func (d *Discovery) broadcast(apps map[string]*naming.InstancesInfo) {
for appID, v := range apps {
var count int
// v maybe nil in old version(less than v1.1) discovery,check incase of panic
if v==nil {
continue
}
for zone, ins := range v.Instances {
if len(ins) == 0 {
delete(v.Instances, zone)