Skip to content

Commit f2c1ee7

Browse files
committed
fix(contrib/registry/servicecomb): wrong stop ticker
1 parent 3d1af9a commit f2c1ee7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

contrib/registry/servicecomb/registry.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ func (r *Registry) Register(_ context.Context, svcIns *registry.ServiceInstance)
124124
// 保存当前版本微服务对应的sid
125125
curServiceID = sid
126126
}
127-
props := make(map[string]string)
128-
props[appIDKey] = appID
129-
props[envKey] = env
130127
if svcIns.ID == "" {
131128
var id uuid.UUID
132129
id, err = uuid.NewV4()
@@ -135,6 +132,10 @@ func (r *Registry) Register(_ context.Context, svcIns *registry.ServiceInstance)
135132
}
136133
svcIns.ID = id.String()
137134
}
135+
props := map[string]string{
136+
appIDKey: appID,
137+
envKey: env,
138+
}
138139
_, err = r.cli.RegisterMicroServiceInstance(&discovery.MicroServiceInstance{
139140
InstanceId: svcIns.ID,
140141
ServiceId: sid,
@@ -146,9 +147,9 @@ func (r *Registry) Register(_ context.Context, svcIns *registry.ServiceInstance)
146147
if err != nil {
147148
return err
148149
}
149-
ticker := time.NewTicker(30 * time.Second)
150-
defer ticker.Stop()
151150
go func() {
151+
ticker := time.NewTicker(30 * time.Second)
152+
defer ticker.Stop()
152153
for {
153154
<-ticker.C
154155
_, err = r.cli.Heartbeat(sid, svcIns.ID)

0 commit comments

Comments
 (0)