(skt *channelz.Socket)
| 77 | } |
| 78 | |
| 79 | func socketToProto(skt *channelz.Socket) *channelzpb.Socket { |
| 80 | s := &channelzpb.Socket{} |
| 81 | s.Ref = &channelzpb.SocketRef{SocketId: skt.ID, Name: skt.RefName} |
| 82 | |
| 83 | s.Data = &channelzpb.SocketData{ |
| 84 | StreamsStarted: skt.SocketMetrics.StreamsStarted.Load(), |
| 85 | StreamsSucceeded: skt.SocketMetrics.StreamsSucceeded.Load(), |
| 86 | StreamsFailed: skt.SocketMetrics.StreamsFailed.Load(), |
| 87 | MessagesSent: skt.SocketMetrics.MessagesSent.Load(), |
| 88 | MessagesReceived: skt.SocketMetrics.MessagesReceived.Load(), |
| 89 | KeepAlivesSent: skt.SocketMetrics.KeepAlivesSent.Load(), |
| 90 | } |
| 91 | if ts := timestamppb.New(time.Unix(0, skt.SocketMetrics.LastLocalStreamCreatedTimestamp.Load())); ts.IsValid() { |
| 92 | s.Data.LastLocalStreamCreatedTimestamp = ts |
| 93 | } |
| 94 | if ts := timestamppb.New(time.Unix(0, skt.SocketMetrics.LastRemoteStreamCreatedTimestamp.Load())); ts.IsValid() { |
| 95 | s.Data.LastRemoteStreamCreatedTimestamp = ts |
| 96 | } |
| 97 | if ts := timestamppb.New(time.Unix(0, skt.SocketMetrics.LastMessageSentTimestamp.Load())); ts.IsValid() { |
| 98 | s.Data.LastMessageSentTimestamp = ts |
| 99 | } |
| 100 | if ts := timestamppb.New(time.Unix(0, skt.SocketMetrics.LastMessageReceivedTimestamp.Load())); ts.IsValid() { |
| 101 | s.Data.LastMessageReceivedTimestamp = ts |
| 102 | } |
| 103 | if skt.EphemeralMetrics != nil { |
| 104 | e := skt.EphemeralMetrics() |
| 105 | s.Data.LocalFlowControlWindow = wrapperspb.Int64(e.LocalFlowControlWindow) |
| 106 | s.Data.RemoteFlowControlWindow = wrapperspb.Int64(e.RemoteFlowControlWindow) |
| 107 | } |
| 108 | |
| 109 | s.Data.Option = sockoptToProto(skt.SocketOptions) |
| 110 | s.Security = securityToProto(skt.Security) |
| 111 | s.Local = addrToProto(skt.LocalAddr) |
| 112 | s.Remote = addrToProto(skt.RemoteAddr) |
| 113 | s.RemoteName = skt.RemoteName |
| 114 | return s |
| 115 | } |
| 116 | |
| 117 | // GetServerSockets returns the protobuf representation of the server (listen) |
| 118 | // sockets starting at startID (max of len), and returns end=true if no server |
no test coverage detected