Skip to content

Commit

Permalink
fix(contrib/registry/servicecomb): wrong stop ticker
Browse files Browse the repository at this point in the history
  • Loading branch information
demoManito committed Mar 21, 2023
1 parent 9a973d2 commit e71af04
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions contrib/registry/servicecomb/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ func (r *Registry) Register(_ context.Context, svcIns *registry.ServiceInstance)
// 保存当前版本微服务对应的sid
curServiceID = sid
}
props := make(map[string]string)
props[appIDKey] = appID
props[envKey] = env
if svcIns.ID == "" {
var id uuid.UUID
id, err = uuid.NewV4()
Expand All @@ -135,6 +132,10 @@ func (r *Registry) Register(_ context.Context, svcIns *registry.ServiceInstance)
}
svcIns.ID = id.String()
}
props := map[string]string{
appIDKey: appID,
envKey: env,
}
_, err = r.cli.RegisterMicroServiceInstance(&discovery.MicroServiceInstance{
InstanceId: svcIns.ID,
ServiceId: sid,
Expand All @@ -146,9 +147,9 @@ func (r *Registry) Register(_ context.Context, svcIns *registry.ServiceInstance)
if err != nil {
return err
}
ticker := time.NewTicker(30 * time.Second)
defer ticker.Stop()
go func() {
ticker := time.NewTicker(30 * time.Second)
defer ticker.Stop()
for {
<-ticker.C
_, err = r.cli.Heartbeat(sid, svcIns.ID)
Expand Down

0 comments on commit e71af04

Please sign in to comment.