Strip the verbosity of the debug handler
This commit is contained in:
parent
1db98ee0f0
commit
a63dcda003
@ -4,11 +4,6 @@ import (
|
|||||||
"github.com/micro/go-micro/server/debug"
|
"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) {
|
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)))
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
// used to determine health, status and env info about
|
// used to determine health, status and env info about
|
||||||
// a service node. It's akin to Google's /statusz, /healthz,
|
// a service node. It's akin to Google's /statusz, /healthz,
|
||||||
// and /varz
|
// and /varz
|
||||||
type DebugHandler interface {
|
type Handler interface {
|
||||||
Health(ctx context.Context, req *proto.HealthRequest, rsp *proto.HealthResponse) error
|
Health(ctx context.Context, req *proto.HealthRequest, rsp *proto.HealthResponse) error
|
||||||
Stats(ctx context.Context, req *proto.StatsRequest, rsp *proto.StatsResponse) error
|
Stats(ctx context.Context, req *proto.StatsRequest, rsp *proto.StatsResponse) error
|
||||||
}
|
}
|
||||||
@ -22,8 +22,13 @@ type debug struct {
|
|||||||
started int64
|
started int64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We use this to wrap any debug handlers so we preserve the signature Debug.{Method}
|
||||||
|
type Debug struct {
|
||||||
|
Handler
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
DefaultDebugHandler DebugHandler = newDebug()
|
DefaultHandler Handler = newDebug()
|
||||||
)
|
)
|
||||||
|
|
||||||
func newDebug() *debug {
|
func newDebug() *debug {
|
||||||
|
@ -5,11 +5,6 @@ import (
|
|||||||
"github.com/micro/go-micro/server/debug"
|
"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) {
|
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)))
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ func newOptions(opt ...server.Option) server.Options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if opts.DebugHandler == nil {
|
if opts.DebugHandler == nil {
|
||||||
opts.DebugHandler = debug.DefaultDebugHandler
|
opts.DebugHandler = debug.DefaultHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(opts.Address) == 0 {
|
if len(opts.Address) == 0 {
|
||||||
|
@ -37,7 +37,7 @@ type Options struct {
|
|||||||
Router Router
|
Router Router
|
||||||
|
|
||||||
// Debug Handler which can be set by a user
|
// Debug Handler which can be set by a user
|
||||||
DebugHandler debug.DebugHandler
|
DebugHandler debug.Handler
|
||||||
|
|
||||||
// Other options for implementations of the interface
|
// Other options for implementations of the interface
|
||||||
// can be stored in a context
|
// can be stored in a context
|
||||||
@ -67,7 +67,7 @@ func newOptions(opt ...Option) Options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if opts.DebugHandler == nil {
|
if opts.DebugHandler == nil {
|
||||||
opts.DebugHandler = debug.DefaultDebugHandler
|
opts.DebugHandler = debug.DefaultHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.RegisterCheck == nil {
|
if opts.RegisterCheck == nil {
|
||||||
@ -157,7 +157,7 @@ func Transport(t transport.Transport) Option {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DebugHandler for this server
|
// DebugHandler for this server
|
||||||
func DebugHandler(d debug.DebugHandler) Option {
|
func DebugHandler(d debug.Handler) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.DebugHandler = d
|
o.DebugHandler = d
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user