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
package monitor_key

type MonitorKeyType int

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

Y
Your Name 已提交
18
	MonitorKeyTypeSize = int(ProxyTimeoutCount) + 1
E
eoLinker API Management 已提交
19
)
Y
Your Name 已提交
20

E
eoLinker API Management 已提交
21 22 23 24 25
var (
	keys []MonitorKeyType
)

func init() {
Y
Your Name 已提交
26
	ks := make([]MonitorKeyType, MonitorKeyTypeSize)
E
eoLinker API Management 已提交
27

Y
Your Name 已提交
28
	for i := range ks {
E
eoLinker API Management 已提交
29 30 31 32
		ks[i] = MonitorKeyType(i)
	}
	keys = ks
}
Y
Your Name 已提交
33
func Keys() []MonitorKeyType {
E
eoLinker API Management 已提交
34 35 36
	return keys
}

Y
Your Name 已提交
37
func ToString(key int) string {
E
eoLinker API Management 已提交
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
	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 ""

}