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

Method securityLevelLocked

clientconn.go:1428–1447  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1426type securityLevelKey struct{}
1427
1428func (ac *addrConn) securityLevelLocked() string {
1429 var secLevel string
1430 // During disconnection, ac.transport is nil. Fall back to the security level
1431 // stored in the current address during connection.
1432 if ac.transport == nil {
1433 secLevel, _ = ac.curAddr.Attributes.Value(securityLevelKey{}).(string)
1434 return secLevel
1435 }
1436 authInfo := ac.transport.Peer().AuthInfo
1437 if ci, ok := authInfo.(interface {
1438 GetCommonAuthInfo() credentials.CommonAuthInfo
1439 }); ok {
1440 secLevel = ci.GetCommonAuthInfo().SecurityLevel.String()
1441 // Store the security level in the current address' attributes so
1442 // that it remains available for disconnection metrics after the
1443 // transport is closed.
1444 ac.curAddr.Attributes = ac.curAddr.Attributes.WithValue(securityLevelKey{}, secLevel)
1445 }
1446 return secLevel
1447}
1448
1449// tryAllAddrs tries to create a connection to the addresses, and stop when at
1450// the first successful one. It returns an error if no address was successfully

Callers 2

Calls 5

WithValueMethod · 0.80
PeerMethod · 0.65
StringMethod · 0.65
GetCommonAuthInfoMethod · 0.65
ValueMethod · 0.45

Tested by

no test coverage detected