Strip the verbosity of the debug handler

This commit is contained in:
Asim Aslam 2019-07-28 19:43:50 +01:00
parent 1db98ee0f0
commit a63dcda003
5 changed files with 13 additions and 18 deletions

View File

@ -4,11 +4,6 @@ import (
"github.com/micro/go-micro/server/debug"
)
// We use this to wrap any debug handlers so we preserve the signature Debug.{Method}
type Debug struct {
debug.DebugHandler
}
func registerDebugHandler(s Server) {
s.Handle(s.NewHandler(&Debug{s.Options().DebugHandler}, InternalHandler(true)))
s.Handle(s.NewHandler(&debug.Debug{s.Options().DebugHandler}, InternalHandler(true)))
}

View File

@ -12,7 +12,7 @@ import (
// used to determine health, status and env info about
// a service node. It's akin to Google's /statusz, /healthz,
// and /varz
type DebugHandler interface {
type Handler interface {
Health(ctx context.Context, req *proto.HealthRequest, rsp *proto.HealthResponse) error
Stats(ctx context.Context, req *proto.StatsRequest, rsp *proto.StatsResponse) error
}
@ -22,8 +22,13 @@ type debug struct {
started int64
}
// We use this to wrap any debug handlers so we preserve the signature Debug.{Method}
type Debug struct {
Handler
}
var (
DefaultDebugHandler DebugHandler = newDebug()
DefaultHandler Handler = newDebug()
)
func newDebug() *debug {

View File

@ -5,11 +5,6 @@ import (
"github.com/micro/go-micro/server/debug"
)
// We use this to wrap any debug handlers so we preserve the signature Debug.{Method}
type Debug struct {
debug.DebugHandler
}
func registerDebugHandler(s server.Server) {
s.Handle(s.NewHandler(&Debug{s.Options().DebugHandler}, server.InternalHandler(true)))
s.Handle(s.NewHandler(&debug.Debug{s.Options().DebugHandler}, server.InternalHandler(true)))
}

View File

@ -90,7 +90,7 @@ func newOptions(opt ...server.Option) server.Options {
}
if opts.DebugHandler == nil {
opts.DebugHandler = debug.DefaultDebugHandler
opts.DebugHandler = debug.DefaultHandler
}
if len(opts.Address) == 0 {

View File

@ -37,7 +37,7 @@ type Options struct {
Router Router
// Debug Handler which can be set by a user
DebugHandler debug.DebugHandler
DebugHandler debug.Handler
// Other options for implementations of the interface
// can be stored in a context
@ -67,7 +67,7 @@ func newOptions(opt ...Option) Options {
}
if opts.DebugHandler == nil {
opts.DebugHandler = debug.DefaultDebugHandler
opts.DebugHandler = debug.DefaultHandler
}
if opts.RegisterCheck == nil {
@ -157,7 +157,7 @@ func Transport(t transport.Transport) Option {
}
// DebugHandler for this server
func DebugHandler(d debug.DebugHandler) Option {
func DebugHandler(d debug.Handler) Option {
return func(o *Options) {
o.DebugHandler = d
}