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

Function newSocket

channelz/service/service_test.go:514–552  ·  view source on GitHub ↗
(cs czSocket)

Source from the content-addressed store, hash-verified

512}
513
514func newSocket(cs czSocket) *channelz.Socket {
515 if cs.lastLocalStreamCreatedTimestamp.IsZero() {
516 cs.lastLocalStreamCreatedTimestamp = time.Unix(0, 0)
517 }
518 if cs.lastRemoteStreamCreatedTimestamp.IsZero() {
519 cs.lastRemoteStreamCreatedTimestamp = time.Unix(0, 0)
520 }
521 if cs.lastMessageSentTimestamp.IsZero() {
522 cs.lastMessageSentTimestamp = time.Unix(0, 0)
523 }
524 if cs.lastMessageReceivedTimestamp.IsZero() {
525 cs.lastMessageReceivedTimestamp = time.Unix(0, 0)
526 }
527
528 s := &channelz.Socket{
529 LocalAddr: cs.localAddr,
530 RemoteAddr: cs.remoteAddr,
531 RemoteName: cs.remoteName,
532 SocketOptions: cs.socketOptions,
533 Security: cs.security,
534 }
535 s.SocketMetrics.StreamsStarted.Store(cs.streamsStarted)
536 s.SocketMetrics.StreamsSucceeded.Store(cs.streamsSucceeded)
537 s.SocketMetrics.StreamsFailed.Store(cs.streamsFailed)
538 s.SocketMetrics.MessagesSent.Store(cs.messagesSent)
539 s.SocketMetrics.MessagesReceived.Store(cs.messagesReceived)
540 s.SocketMetrics.KeepAlivesSent.Store(cs.keepAlivesSent)
541 s.SocketMetrics.LastLocalStreamCreatedTimestamp.Store(cs.lastLocalStreamCreatedTimestamp.UnixNano())
542 s.SocketMetrics.LastRemoteStreamCreatedTimestamp.Store(cs.lastRemoteStreamCreatedTimestamp.UnixNano())
543 s.SocketMetrics.LastMessageSentTimestamp.Store(cs.lastMessageSentTimestamp.UnixNano())
544 s.SocketMetrics.LastMessageReceivedTimestamp.Store(cs.lastMessageReceivedTimestamp.UnixNano())
545 s.EphemeralMetrics = func() *channelz.EphemeralSocketMetrics {
546 return &channelz.EphemeralSocketMetrics{
547 LocalFlowControlWindow: cs.localFlowControlWindow,
548 RemoteFlowControlWindow: cs.remoteFlowControlWindow,
549 }
550 }
551 return s
552}
553
554type OtherChannelzSecurityValue struct {
555 LocalCertificate []byte `protobuf:"bytes,1,opt,name=local_certificate,json=localCertificate,proto3" json:"local_certificate,omitempty"`

Callers 1

TestGetSocketMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected