mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
Fresh dep ensure
This commit is contained in:
71
vendor/google.golang.org/grpc/channelz/service/service.go
generated
vendored
71
vendor/google.golang.org/grpc/channelz/service/service.go
generated
vendored
@ -23,20 +23,31 @@ package service
|
||||
|
||||
import (
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
durpb "github.com/golang/protobuf/ptypes/duration"
|
||||
wrpb "github.com/golang/protobuf/ptypes/wrappers"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
channelzgrpc "google.golang.org/grpc/channelz/grpc_channelz_v1"
|
||||
channelzpb "google.golang.org/grpc/channelz/grpc_channelz_v1"
|
||||
"google.golang.org/grpc/connectivity"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/internal/channelz"
|
||||
)
|
||||
|
||||
func init() {
|
||||
channelz.TurnOn()
|
||||
}
|
||||
|
||||
func convertToPtypesDuration(sec int64, usec int64) *durpb.Duration {
|
||||
return ptypes.DurationProto(time.Duration(sec*1e9 + usec*1e3))
|
||||
}
|
||||
|
||||
// RegisterChannelzServiceToServer registers the channelz service to the given server.
|
||||
func RegisterChannelzServiceToServer(s *grpc.Server) {
|
||||
channelzgrpc.RegisterChannelzServer(s, &serverImpl{})
|
||||
channelzgrpc.RegisterChannelzServer(s, newCZServer())
|
||||
}
|
||||
|
||||
func newCZServer() channelzgrpc.ChannelzServer {
|
||||
@ -62,6 +73,35 @@ func connectivityStateToProto(s connectivity.State) *channelzpb.ChannelConnectiv
|
||||
}
|
||||
}
|
||||
|
||||
func channelTraceToProto(ct *channelz.ChannelTrace) *channelzpb.ChannelTrace {
|
||||
pbt := &channelzpb.ChannelTrace{}
|
||||
pbt.NumEventsLogged = ct.EventNum
|
||||
if ts, err := ptypes.TimestampProto(ct.CreationTime); err == nil {
|
||||
pbt.CreationTimestamp = ts
|
||||
}
|
||||
var events []*channelzpb.ChannelTraceEvent
|
||||
for _, e := range ct.Events {
|
||||
cte := &channelzpb.ChannelTraceEvent{
|
||||
Description: e.Desc,
|
||||
Severity: channelzpb.ChannelTraceEvent_Severity(e.Severity),
|
||||
}
|
||||
if ts, err := ptypes.TimestampProto(e.Timestamp); err == nil {
|
||||
cte.Timestamp = ts
|
||||
}
|
||||
if e.RefID != 0 {
|
||||
switch e.RefType {
|
||||
case channelz.RefChannel:
|
||||
cte.ChildRef = &channelzpb.ChannelTraceEvent_ChannelRef{ChannelRef: &channelzpb.ChannelRef{ChannelId: e.RefID, Name: e.RefName}}
|
||||
case channelz.RefSubChannel:
|
||||
cte.ChildRef = &channelzpb.ChannelTraceEvent_SubchannelRef{SubchannelRef: &channelzpb.SubchannelRef{SubchannelId: e.RefID, Name: e.RefName}}
|
||||
}
|
||||
}
|
||||
events = append(events, cte)
|
||||
}
|
||||
pbt.Events = events
|
||||
return pbt
|
||||
}
|
||||
|
||||
func channelMetricToProto(cm *channelz.ChannelMetric) *channelzpb.Channel {
|
||||
c := &channelzpb.Channel{}
|
||||
c.Ref = &channelzpb.ChannelRef{ChannelId: cm.ID, Name: cm.RefName}
|
||||
@ -93,6 +133,7 @@ func channelMetricToProto(cm *channelz.ChannelMetric) *channelzpb.Channel {
|
||||
sockets = append(sockets, &channelzpb.SocketRef{SocketId: id, Name: ref})
|
||||
}
|
||||
c.SocketRef = sockets
|
||||
c.Data.Trace = channelTraceToProto(cm.Trace)
|
||||
return c
|
||||
}
|
||||
|
||||
@ -127,9 +168,30 @@ func subChannelMetricToProto(cm *channelz.SubChannelMetric) *channelzpb.Subchann
|
||||
sockets = append(sockets, &channelzpb.SocketRef{SocketId: id, Name: ref})
|
||||
}
|
||||
sc.SocketRef = sockets
|
||||
sc.Data.Trace = channelTraceToProto(cm.Trace)
|
||||
return sc
|
||||
}
|
||||
|
||||
func securityToProto(se credentials.ChannelzSecurityValue) *channelzpb.Security {
|
||||
switch v := se.(type) {
|
||||
case *credentials.TLSChannelzSecurityValue:
|
||||
return &channelzpb.Security{Model: &channelzpb.Security_Tls_{Tls: &channelzpb.Security_Tls{
|
||||
CipherSuite: &channelzpb.Security_Tls_StandardName{StandardName: v.StandardName},
|
||||
LocalCertificate: v.LocalCertificate,
|
||||
RemoteCertificate: v.RemoteCertificate,
|
||||
}}}
|
||||
case *credentials.OtherChannelzSecurityValue:
|
||||
otherSecurity := &channelzpb.Security_OtherSecurity{
|
||||
Name: v.Name,
|
||||
}
|
||||
if anyval, err := ptypes.MarshalAny(v.Value); err == nil {
|
||||
otherSecurity.Value = anyval
|
||||
}
|
||||
return &channelzpb.Security{Model: &channelzpb.Security_Other{Other: otherSecurity}}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func addrToProto(a net.Addr) *channelzpb.Address {
|
||||
switch a.Network() {
|
||||
case "udp":
|
||||
@ -177,6 +239,13 @@ func socketMetricToProto(sm *channelz.SocketMetric) *channelzpb.Socket {
|
||||
s.Data.LocalFlowControlWindow = &wrpb.Int64Value{Value: sm.SocketData.LocalFlowControlWindow}
|
||||
s.Data.RemoteFlowControlWindow = &wrpb.Int64Value{Value: sm.SocketData.RemoteFlowControlWindow}
|
||||
|
||||
if sm.SocketData.SocketOptions != nil {
|
||||
s.Data.Option = sockoptToProto(sm.SocketData.SocketOptions)
|
||||
}
|
||||
if sm.SocketData.Security != nil {
|
||||
s.Security = securityToProto(sm.SocketData.Security)
|
||||
}
|
||||
|
||||
if sm.SocketData.LocalAddr != nil {
|
||||
s.Local = addrToProto(sm.SocketData.LocalAddr)
|
||||
}
|
||||
|
Reference in New Issue
Block a user