|
|
@ -124,9 +124,6 @@ func (r *Registry) Register(_ context.Context, svcIns *registry.ServiceInstance) |
|
|
|
// 保存当前版本微服务对应的sid
|
|
|
|
// 保存当前版本微服务对应的sid
|
|
|
|
curServiceID = sid |
|
|
|
curServiceID = sid |
|
|
|
} |
|
|
|
} |
|
|
|
props := make(map[string]string) |
|
|
|
|
|
|
|
props[appIDKey] = appID |
|
|
|
|
|
|
|
props[envKey] = env |
|
|
|
|
|
|
|
if svcIns.ID == "" { |
|
|
|
if svcIns.ID == "" { |
|
|
|
var id uuid.UUID |
|
|
|
var id uuid.UUID |
|
|
|
id, err = uuid.NewV4() |
|
|
|
id, err = uuid.NewV4() |
|
|
@ -135,6 +132,10 @@ func (r *Registry) Register(_ context.Context, svcIns *registry.ServiceInstance) |
|
|
|
} |
|
|
|
} |
|
|
|
svcIns.ID = id.String() |
|
|
|
svcIns.ID = id.String() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
props := map[string]string{ |
|
|
|
|
|
|
|
appIDKey: appID, |
|
|
|
|
|
|
|
envKey: env, |
|
|
|
|
|
|
|
} |
|
|
|
_, err = r.cli.RegisterMicroServiceInstance(&discovery.MicroServiceInstance{ |
|
|
|
_, err = r.cli.RegisterMicroServiceInstance(&discovery.MicroServiceInstance{ |
|
|
|
InstanceId: svcIns.ID, |
|
|
|
InstanceId: svcIns.ID, |
|
|
|
ServiceId: sid, |
|
|
|
ServiceId: sid, |
|
|
@ -146,9 +147,9 @@ func (r *Registry) Register(_ context.Context, svcIns *registry.ServiceInstance) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
ticker := time.NewTicker(30 * time.Second) |
|
|
|
|
|
|
|
defer ticker.Stop() |
|
|
|
|
|
|
|
go func() { |
|
|
|
go func() { |
|
|
|
|
|
|
|
ticker := time.NewTicker(30 * time.Second) |
|
|
|
|
|
|
|
defer ticker.Stop() |
|
|
|
for { |
|
|
|
for { |
|
|
|
<-ticker.C |
|
|
|
<-ticker.C |
|
|
|
_, err = r.cli.Heartbeat(sid, svcIns.ID) |
|
|
|
_, err = r.cli.Heartbeat(sid, svcIns.ID) |
|
|
|