MCPcopy Index your code
hub / github.com/dearcode/candy / healthCheck

Method healthCheck

client/candy.go:356–379  ·  view source on GitHub ↗

healthCheck 健康检查

()

Source from the content-addressed store, hash-verified

354
355// healthCheck 健康检查
356func (c *CandyClient) healthCheck() {
357 for !c.stop {
358 time.Sleep(time.Second)
359 req := &healthpb.HealthCheckRequest{
360 Service: "",
361 }
362
363 _, err := c.health.Check(context.Background(), req)
364 if err != nil {
365 //确保异常只会调用一次
366 if c.bhealth {
367 c.bhealth = false
368 c.handler.OnUnHealth(err.Error())
369 }
370 continue
371 }
372
373 //由异常到正常
374 if !c.bhealth {
375 c.bhealth = true
376 c.handler.OnHealth()
377 }
378 }
379}
380
381// Heartbeat 向服务器发送心跳信息
382func (c *CandyClient) Heartbeat() error {

Callers 1

StartMethod · 0.95

Calls 3

OnUnHealthMethod · 0.65
OnHealthMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected