(cm *channelz.Channel)
| 83 | } |
| 84 | |
| 85 | func channelToProto(cm *channelz.Channel) *channelzpb.Channel { |
| 86 | c := &channelzpb.Channel{} |
| 87 | c.Ref = &channelzpb.ChannelRef{ChannelId: cm.ID, Name: cm.RefName} |
| 88 | |
| 89 | c.Data = &channelzpb.ChannelData{ |
| 90 | State: connectivityStateToProto(cm.ChannelMetrics.State.Load()), |
| 91 | Target: strFromPointer(cm.ChannelMetrics.Target.Load()), |
| 92 | CallsStarted: cm.ChannelMetrics.CallsStarted.Load(), |
| 93 | CallsSucceeded: cm.ChannelMetrics.CallsSucceeded.Load(), |
| 94 | CallsFailed: cm.ChannelMetrics.CallsFailed.Load(), |
| 95 | } |
| 96 | if ts := timestamppb.New(time.Unix(0, cm.ChannelMetrics.LastCallStartedTimestamp.Load())); ts.IsValid() { |
| 97 | c.Data.LastCallStartedTimestamp = ts |
| 98 | } |
| 99 | ncs := cm.NestedChans() |
| 100 | nestedChans := make([]*channelzpb.ChannelRef, 0, len(ncs)) |
| 101 | for id, ref := range ncs { |
| 102 | nestedChans = append(nestedChans, &channelzpb.ChannelRef{ChannelId: id, Name: ref}) |
| 103 | } |
| 104 | c.ChannelRef = nestedChans |
| 105 | |
| 106 | scs := cm.SubChans() |
| 107 | subChans := make([]*channelzpb.SubchannelRef, 0, len(scs)) |
| 108 | for id, ref := range scs { |
| 109 | subChans = append(subChans, &channelzpb.SubchannelRef{SubchannelId: id, Name: ref}) |
| 110 | } |
| 111 | c.SubchannelRef = subChans |
| 112 | |
| 113 | c.Data.Trace = channelTraceToProto(cm.Trace()) |
| 114 | return c |
| 115 | } |
| 116 | |
| 117 | // GetTopChannels returns the protobuf representation of the channels starting |
| 118 | // at startID (max of len), and returns end=true if no top channels exist with |
no test coverage detected