(cm *channelz.SubChannel)
| 30 | ) |
| 31 | |
| 32 | func 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. |
no test coverage detected