micro/server/debug_handler.go
Jelmer Snoeck 0d749eb732 DebugHandler: add default health checker.
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.
2016-01-06 17:05:22 +00:00

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))
}