-
Notifications
You must be signed in to change notification settings - Fork 129
/
trace.go
31 lines (26 loc) · 856 Bytes
/
trace.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package handler_ctrl
import (
"github.com/michaelquigley/pfxlog"
"github.com/openziti/channel/v2"
"github.com/openziti/channel/v2/trace/pb"
"github.com/openziti/ziti/common/pb/ctrl_pb"
"github.com/openziti/ziti/common/trace"
"google.golang.org/protobuf/proto"
)
type traceHandler struct {
dispatcher trace.EventHandler
}
func newTraceHandler(dispatcher trace.EventHandler) *traceHandler {
return &traceHandler{dispatcher: dispatcher}
}
func (*traceHandler) ContentType() int32 {
return int32(ctrl_pb.ContentType_TraceEventType)
}
func (handler *traceHandler) HandleReceive(msg *channel.Message, _ channel.Channel) {
event := &trace_pb.ChannelMessage{}
if err := proto.Unmarshal(msg.Body, event); err == nil {
go handler.dispatcher.Accept(event)
} else {
pfxlog.Logger().Errorf("unexpected error decoding trace message (%s)", err)
}
}