MCPcopy
hub / github.com/grpc/grpc-go / subChannelToProto

Function subChannelToProto

channelz/internal/protoconv/subchannel.go:32–55  ·  view source on GitHub ↗
(cm *channelz.SubChannel)

Source from the content-addressed store, hash-verified

30)
31
32func subChannelToProto(cm *channelz.SubChannel) *channelzpb.Subchannel {
33 sc := &channelzpb.Subchannel{}
34 sc.Ref = &channelzpb.SubchannelRef{SubchannelId: cm.ID, Name: cm.RefName}
35
36 sc.Data = &channelzpb.ChannelData{
37 State: connectivityStateToProto(cm.ChannelMetrics.State.Load()),
38 Target: strFromPointer(cm.ChannelMetrics.Target.Load()),
39 CallsStarted: cm.ChannelMetrics.CallsStarted.Load(),
40 CallsSucceeded: cm.ChannelMetrics.CallsSucceeded.Load(),
41 CallsFailed: cm.ChannelMetrics.CallsFailed.Load(),
42 }
43 if ts := timestamppb.New(time.Unix(0, cm.ChannelMetrics.LastCallStartedTimestamp.Load())); ts.IsValid() {
44 sc.Data.LastCallStartedTimestamp = ts
45 }
46
47 skts := cm.Sockets()
48 sockets := make([]*channelzpb.SocketRef, 0, len(skts))
49 for id, ref := range skts {
50 sockets = append(sockets, &channelzpb.SocketRef{SocketId: id, Name: ref})
51 }
52 sc.SocketRef = sockets
53 sc.Data.Trace = channelTraceToProto(cm.Trace())
54 return sc
55}
56
57// GetSubChannel returns the protobuf representation of the subchannel with the
58// given ID.

Callers 1

GetSubChannelFunction · 0.85

Calls 6

connectivityStateToProtoFunction · 0.85
channelTraceToProtoFunction · 0.85
SocketsMethod · 0.80
strFromPointerFunction · 0.70
LoadMethod · 0.45
TraceMethod · 0.45

Tested by

no test coverage detected