53 lines
1.5 KiB
Go
53 lines
1.5 KiB
Go
package consts
|
|
|
|
// AdSourceHealth 广告源健康状态枚举
|
|
type AdSourceHealth string
|
|
|
|
const (
|
|
AdSourceHealthHealthy AdSourceHealth = "healthy" // 健康
|
|
AdSourceHealthDegraded AdSourceHealth = "degraded" // 降级
|
|
AdSourceHealthUnhealthy AdSourceHealth = "unhealthy" // 不健康
|
|
)
|
|
|
|
// GetAllAdSourceHealths 获取所有广告源健康状态
|
|
func GetAllAdSourceHealths() []AdSourceHealth {
|
|
return []AdSourceHealth{
|
|
AdSourceHealthHealthy,
|
|
AdSourceHealthDegraded,
|
|
AdSourceHealthUnhealthy,
|
|
}
|
|
}
|
|
|
|
type AdSourceHealthKeyValue struct {
|
|
Key AdSourceHealth
|
|
Value string
|
|
}
|
|
|
|
var (
|
|
AdSourceHealthHealthyKeyValue = AdSourceHealthKeyValue{Key: AdSourceHealthHealthy, Value: "健康"}
|
|
AdSourceHealthDegradedKeyValue = AdSourceHealthKeyValue{Key: AdSourceHealthDegraded, Value: "降级"}
|
|
AdSourceHealthUnhealthyKeyValue = AdSourceHealthKeyValue{Key: AdSourceHealthUnhealthy, Value: "不健康"}
|
|
)
|
|
|
|
func GetAllAdSourceHealthKeyValue() []AdSourceHealthKeyValue {
|
|
return []AdSourceHealthKeyValue{
|
|
AdSourceHealthHealthyKeyValue,
|
|
AdSourceHealthDegradedKeyValue,
|
|
AdSourceHealthUnhealthyKeyValue,
|
|
}
|
|
}
|
|
|
|
var adSourceHealthValueMap = map[AdSourceHealth]string{
|
|
AdSourceHealthHealthy: AdSourceHealthHealthyKeyValue.Value,
|
|
AdSourceHealthDegraded: AdSourceHealthDegradedKeyValue.Value,
|
|
AdSourceHealthUnhealthy: AdSourceHealthUnhealthyKeyValue.Value,
|
|
}
|
|
|
|
func GetAdSourceHealthValueByKey(key AdSourceHealth) (value string) {
|
|
value, exists := adSourceHealthValueMap[key]
|
|
if !exists {
|
|
value = "未知健康状态"
|
|
}
|
|
return
|
|
}
|