key.go 1.3 KB
Newer Older
E
eoLinker API Management 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
package monitor_key

type MonitorKeyType int

const (
	GatewayRequestCount MonitorKeyType = iota
	GatewaySuccessCount
	GatewayStatus2xxCount
	GatewayStatus4xxCount
	GatewayStatus5xxCount
	ProxyRequestCount
	ProxySuccessCount
	ProxyStatus2xxCount
	ProxyStatus4xxCount
	ProxyStatus5xxCount
	ProxyTimeoutCount


	MonitorKeyTypeSize = int(ProxyTimeoutCount)+1

)
var (
	keys []MonitorKeyType
)

func init() {
	ks:=make([]MonitorKeyType,MonitorKeyTypeSize)

	for i:=range ks{
		ks[i] = MonitorKeyType(i)
	}
	keys = ks
}
func Keys()[]MonitorKeyType  {
	return keys
}

func ToString(key int)string  {
	return MonitorKeyType(key).String()
}
func (t MonitorKeyType) String() string {
	switch t {
	case GatewayRequestCount:
		return "gatewayRequestCount"
	case GatewaySuccessCount:
		return "gatewaySuccessCount"
	case GatewayStatus2xxCount:
		return "gatewayStatus2xxCount"
	case GatewayStatus4xxCount:
		return "gatewayStatus4xxCount"
	case GatewayStatus5xxCount:
		return "gatewayStatus5xxCount"
	case ProxyRequestCount:
		return "proxyRequestCount"
	case ProxySuccessCount:
		return "proxySuccessCount"
	case ProxyStatus2xxCount:
		return "proxyStatus2xxCount"
	case ProxyStatus4xxCount:
		return "proxyStatus4xxCount"
	case ProxyStatus5xxCount:
		return "proxyStatus5xxCount"
	case ProxyTimeoutCount:
		return "proxyTimeoutCount"
	}
	return ""

}