2015-01-14 02:31:27 +03:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2015-11-20 19:17:33 +03:00
|
|
|
"github.com/micro/go-micro/server/proto/health"
|
2015-05-22 01:06:01 +03:00
|
|
|
"golang.org/x/net/context"
|
2015-01-14 02:31:27 +03:00
|
|
|
)
|
|
|
|
|
2016-01-06 20:03:31 +03:00
|
|
|
type (
|
|
|
|
HealthChecker interface {
|
|
|
|
Health(ctx context.Context, req *health.Request, rsp *health.Response) error
|
|
|
|
}
|
|
|
|
|
|
|
|
Debug struct{}
|
|
|
|
)
|
|
|
|
|
|
|
|
var DefaultHealthChecker HealthChecker = new(Debug)
|
2015-05-22 01:06:01 +03:00
|
|
|
|
|
|
|
func (d *Debug) Health(ctx context.Context, req *health.Request, rsp *health.Response) error {
|
|
|
|
rsp.Status = "ok"
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-06-03 03:25:37 +03:00
|
|
|
func registerHealthChecker(s Server) {
|
2016-01-06 20:03:31 +03:00
|
|
|
s.Handle(s.NewHandler(DefaultHealthChecker))
|
2015-01-14 02:31:27 +03:00
|
|
|
}
|