Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ultra hacks to make debug handler work in proxy #1007

Merged
merged 1 commit into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
ultra hacks to make debug handler work in proxy
  • Loading branch information
asim committed Dec 2, 2019
commit 91e9c0cb622e5e4a6118cb97059915cbef953f38
11 changes: 8 additions & 3 deletions debug/handler/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"time"

"github.com/micro/go-micro/debug/log"

proto "github.com/micro/go-micro/debug/proto"
"github.com/micro/go-micro/server"
)

var (
Expand Down Expand Up @@ -46,7 +46,12 @@ func (d *Debug) Stats(ctx context.Context, req *proto.StatsRequest, rsp *proto.S
return nil
}

func (d *Debug) Logs(ctx context.Context, req *proto.LogRequest, stream proto.Debug_LogsStream) error {
func (d *Debug) Logs(ctx context.Context, stream server.Stream) error {
req := new(proto.LogRequest)
if err := stream.Recv(req); err != nil {
return err
}

var options []log.ReadOption

since := time.Unix(req.Since, 0)
Expand Down Expand Up @@ -90,7 +95,7 @@ func (d *Debug) Logs(ctx context.Context, req *proto.LogRequest, stream proto.De
return nil
}

func (d *Debug) sendRecord(record log.Record, stream proto.Debug_LogsStream) error {
func (d *Debug) sendRecord(record log.Record, stream server.Stream) error {
metadata := make(map[string]string)
for k, v := range record.Metadata {
metadata[k] = v
Expand Down
11 changes: 6 additions & 5 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import (
"github.com/micro/go-micro/server"
"github.com/micro/go-micro/util/log"
"github.com/micro/go-micro/util/wrapper"

pb "github.com/micro/go-micro/debug/proto"
)

type service struct {
Expand Down Expand Up @@ -143,9 +141,12 @@ func (s *service) Stop() error {

func (s *service) Run() error {
// register the debug handler
pb.RegisterDebugHandler(s.opts.Server,
handler.DefaultHandler,
server.InternalHandler(true))
s.opts.Server.Handle(
s.opts.Server.NewHandler(
handler.DefaultHandler,
server.InternalHandler(true),
),
)

// start the profiler
// TODO: set as an option to the service, don't just use pprof
Expand Down
10 changes: 5 additions & 5 deletions util/mux/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"sync"

proto "github.com/micro/go-micro/debug/proto"
"github.com/micro/go-micro/debug/handler"
"github.com/micro/go-micro/proxy"
"github.com/micro/go-micro/server"
Expand Down Expand Up @@ -40,10 +39,11 @@ func (s *Server) ServeRequest(ctx context.Context, req server.Request, rsp serve
func New(name string, p proxy.Proxy) *Server {
// only register this once
once.Do(func() {
proto.RegisterDebugHandler(
server.DefaultServer,
handler.DefaultHandler,
server.InternalHandler(true),
server.DefaultRouter.Handle(
server.DefaultRouter.NewHandler(
handler.DefaultHandler,
server.InternalHandler(true),
),
)
})

Expand Down