Add debug routes for eventbus & corredor service
This commit is contained in:
@@ -2,6 +2,9 @@ package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cortezaproject/corteza-server/pkg/corredor"
|
||||
"github.com/cortezaproject/corteza-server/pkg/eventbus"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"runtime"
|
||||
@@ -29,3 +32,15 @@ func debugRoutes(r chi.Routes) http.HandlerFunc {
|
||||
printRoutes(r, "")
|
||||
}
|
||||
}
|
||||
|
||||
func debugEventbus() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, req *http.Request) {
|
||||
spew.Fdump(w, eventbus.Service().Debug())
|
||||
}
|
||||
}
|
||||
|
||||
func debugCorredor() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, req *http.Request) {
|
||||
spew.Fdump(w, corredor.Service().Debug())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +103,12 @@ func (s server) Serve(ctx context.Context) {
|
||||
|
||||
s.log.Debug("list of routes: /__routes", zap.Error(err))
|
||||
router.Get("/__routes", debugRoutes(router))
|
||||
|
||||
s.log.Debug("eventbus handlers: /__eventbus", zap.Error(err))
|
||||
router.Get("/__eventbus", debugEventbus())
|
||||
|
||||
s.log.Debug("corredor service: /__corredor", zap.Error(err))
|
||||
router.Get("/__corredor", debugCorredor())
|
||||
}
|
||||
|
||||
if s.httpOpt.EnableVersionRoute {
|
||||
|
||||
@@ -746,3 +746,12 @@ func (svc *service) GetBundle(ctx context.Context, name, bType string) *Bundle {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (svc *service) Debug() interface{} {
|
||||
return map[string]interface{}{
|
||||
"registered": svc.registered,
|
||||
"explicit": svc.explicit,
|
||||
"server-scripts": svc.sScripts,
|
||||
"client-scripts": svc.cScripts,
|
||||
}
|
||||
}
|
||||
|
||||
14
pkg/eventbus/debug.go
Normal file
14
pkg/eventbus/debug.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package eventbus
|
||||
|
||||
// Debug returns structured debug data
|
||||
func (b *eventbus) Debug() interface{} {
|
||||
var (
|
||||
o = make([]*handler, 0, len(b.handlers))
|
||||
)
|
||||
|
||||
for _, h := range b.handlers {
|
||||
o = append(o, h)
|
||||
}
|
||||
|
||||
return o
|
||||
}
|
||||
Reference in New Issue
Block a user