本文整理汇总了Golang中github.com/Comcast/traffic_control/traffic_monitor/experimental/traffic_monitor/peer.CRStatesThreadsafe.SetDeliveryServices方法的典型用法代码示例。如果您正苦于以下问题:Golang CRStatesThreadsafe.SetDeliveryServices方法的具体用法?Golang CRStatesThreadsafe.SetDeliveryServices怎么用?Golang CRStatesThreadsafe.SetDeliveryServices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Comcast/traffic_control/traffic_monitor/experimental/traffic_monitor/peer.CRStatesThreadsafe
的用法示例。
在下文中一共展示了CRStatesThreadsafe.SetDeliveryServices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: calculateDeliveryServiceState
// calculateDeliveryServiceState calculates the state of delivery services from the new cache state data `cacheState` and the CRConfig data `deliveryServiceServers` and puts the calculated state in the outparam `deliveryServiceStates`
func calculateDeliveryServiceState(deliveryServiceServers map[enum.DeliveryServiceName][]enum.CacheName, states peer.CRStatesThreadsafe) {
deliveryServices := states.GetDeliveryServices()
for deliveryServiceName, deliveryServiceState := range deliveryServices {
if _, ok := deliveryServiceServers[deliveryServiceName]; !ok {
// log.Errorf("CRConfig does not have delivery service %s, but traffic monitor poller does; skipping\n", deliveryServiceName)
continue
}
deliveryServiceState.IsAvailable = false
deliveryServiceState.DisabledLocations = []enum.CacheName{} // it's important this isn't nil, so it serialises to the JSON `[]` instead of `null`
for _, server := range deliveryServiceServers[deliveryServiceName] {
if states.GetCache(server).IsAvailable {
deliveryServiceState.IsAvailable = true
} else {
deliveryServiceState.DisabledLocations = append(deliveryServiceState.DisabledLocations, server)
}
}
deliveryServices[deliveryServiceName] = deliveryServiceState
}
states.SetDeliveryServices(deliveryServices)
}
示例2: calculateDeliveryServiceState
// calculateDeliveryServiceState calculates the state of delivery services from the new cache state data `cacheState` and the CRConfig data `deliveryServiceServers` and puts the calculated state in the outparam `deliveryServiceStates`
func calculateDeliveryServiceState(deliveryServiceServers map[string][]string, states peer.CRStatesThreadsafe) {
deliveryServices := states.GetDeliveryServices()
for deliveryServiceName, deliveryServiceState := range deliveryServices {
if _, ok := deliveryServiceServers[deliveryServiceName]; !ok {
// log.Errorf("CRConfig does not have delivery service %s, but traffic monitor poller does; skipping\n", deliveryServiceName)
continue
}
deliveryServiceState.IsAvailable = false
deliveryServiceState.DisabledLocations = nil
for _, server := range deliveryServiceServers[deliveryServiceName] {
if states.GetCache(server).IsAvailable {
deliveryServiceState.IsAvailable = true
} else {
deliveryServiceState.DisabledLocations = append(deliveryServiceState.DisabledLocations, server)
}
}
deliveryServices[deliveryServiceName] = deliveryServiceState
}
states.SetDeliveryServices(deliveryServices)
}