addChannelzTraceEvent adds a channelz trace event containing the new state received from resolver implementations.
(s resolver.State)
| 188 | // addChannelzTraceEvent adds a channelz trace event containing the new |
| 189 | // state received from resolver implementations. |
| 190 | func (ccr *ccResolverWrapper) addChannelzTraceEvent(s resolver.State) { |
| 191 | if !logger.V(0) && !channelz.IsOn() { |
| 192 | return |
| 193 | } |
| 194 | var updates []string |
| 195 | var oldSC, newSC *ServiceConfig |
| 196 | var oldOK, newOK bool |
| 197 | if ccr.curState.ServiceConfig != nil { |
| 198 | oldSC, oldOK = ccr.curState.ServiceConfig.Config.(*ServiceConfig) |
| 199 | } |
| 200 | if s.ServiceConfig != nil { |
| 201 | newSC, newOK = s.ServiceConfig.Config.(*ServiceConfig) |
| 202 | } |
| 203 | if oldOK != newOK || (oldOK && newOK && oldSC.rawJSONString != newSC.rawJSONString) { |
| 204 | updates = append(updates, "service config updated") |
| 205 | } |
| 206 | if len(ccr.curState.Addresses) > 0 && len(s.Addresses) == 0 { |
| 207 | updates = append(updates, "resolver returned an empty address list") |
| 208 | } else if len(ccr.curState.Addresses) == 0 && len(s.Addresses) > 0 { |
| 209 | updates = append(updates, "resolver returned new addresses") |
| 210 | } |
| 211 | channelz.Infof(logger, ccr.cc.channelz, "Resolver state updated: %s (%v)", pretty.ToJSON(s), strings.Join(updates, "; ")) |
| 212 | } |
| 213 | |
| 214 | func addressesToEndpoints(addrs []resolver.Address) []resolver.Endpoint { |
| 215 | endpoints := make([]resolver.Endpoint, 0, len(addrs)) |
no test coverage detected