mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-24 10:07:04 +02:00
0d749eb732
By using a DefaultHealthChecker - as with a DefaultName, DefaultServer, ... - it is possible to overwrite the default implementation. This means we can now do extra actions in our health check that is necessary for the applications specific needs.
26 lines
510 B
Go
26 lines
510 B
Go
package server
|
|
|
|
import (
|
|
"github.com/micro/go-micro/server/proto/health"
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
type (
|
|
HealthChecker interface {
|
|
Health(ctx context.Context, req *health.Request, rsp *health.Response) error
|
|
}
|
|
|
|
Debug struct{}
|
|
)
|
|
|
|
var DefaultHealthChecker HealthChecker = new(Debug)
|
|
|
|
func (d *Debug) Health(ctx context.Context, req *health.Request, rsp *health.Response) error {
|
|
rsp.Status = "ok"
|
|
return nil
|
|
}
|
|
|
|
func registerHealthChecker(s Server) {
|
|
s.Handle(s.NewHandler(DefaultHealthChecker))
|
|
}
|