From a63dcda0035eafab7fc583e9cd57424ded0a5b37 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Sun, 28 Jul 2019 19:43:50 +0100 Subject: [PATCH] Strip the verbosity of the debug handler --- server/debug.go | 7 +------ server/debug/debug.go | 9 +++++++-- server/grpc/debug.go | 7 +------ server/grpc/options.go | 2 +- server/options.go | 6 +++--- 5 files changed, 13 insertions(+), 18 deletions(-) diff --git a/server/debug.go b/server/debug.go index 18225cf7..72cc88a7 100644 --- a/server/debug.go +++ b/server/debug.go @@ -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))) } diff --git a/server/debug/debug.go b/server/debug/debug.go index f185209d..dc2fa8c7 100644 --- a/server/debug/debug.go +++ b/server/debug/debug.go @@ -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 { diff --git a/server/grpc/debug.go b/server/grpc/debug.go index 5f235346..782b8b1e 100644 --- a/server/grpc/debug.go +++ b/server/grpc/debug.go @@ -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))) } diff --git a/server/grpc/options.go b/server/grpc/options.go index 65d82fcc..4a3bef1d 100644 --- a/server/grpc/options.go +++ b/server/grpc/options.go @@ -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 { diff --git a/server/options.go b/server/options.go index 15de9b83..0d0ee51f 100644 --- a/server/options.go +++ b/server/options.go @@ -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 }