本文整理匯總了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)
}