pull/2481/head
FengbinShi 2 years ago
parent cca30c9c80
commit 24a2850265
  1. 8
      health/checker.go
  2. 9
      health/health_test.go

@ -2,6 +2,7 @@ package health
import (
"context"
"fmt"
"sync"
"time"
)
@ -53,10 +54,13 @@ func (c *checkerHandler) getName() string {
return c.Name
}
func (c *checkerHandler) check(ctx context.Context) bool {
func (c *checkerHandler) check(ctx context.Context) (r bool) {
defer func() {
if err := recover(); err != nil {
r = true
c.Lock()
c.CheckerStatus.Err = fmt.Errorf("%v", err)
c.Unlock()
}
}()

@ -2,14 +2,14 @@ package health
import (
"fmt"
"golang.org/x/net/context"
"math/rand"
"testing"
"time"
"golang.org/x/net/context"
)
type A struct {
}
type A struct{}
func (A) Check(ctx context.Context) (interface{}, error) {
fmt.Println("check A")
@ -19,8 +19,7 @@ func (A) Check(ctx context.Context) (interface{}, error) {
return "正常A", nil
}
type B struct {
}
type B struct{}
func (B) Check(ctx context.Context) (interface{}, error) {
fmt.Println("check B")

Loading…
Cancel
Save