redis.go 901 字节
Newer Older
Y
Your Name 已提交
1
package monitorkey
E
eoLinker API Management 已提交
2 3 4 5 6

import (
	"bytes"
)

Y
Your Name 已提交
7
//StrategyMapKey 策略字典Key
Y
Your Name 已提交
8 9
func StrategyMapKey(cluster, now string) string {
	key := splicing("monitor-strategy:", cluster, ":", now)
E
eoLinker API Management 已提交
10 11 12
	//fmt.Println("StrategyMapKey:",key)
	return key
}
Y
Your Name 已提交
13 14 15 16 17

//APIMapKey 接口字典key
func APIMapKey(cluster, strategyID, now string) string {
	key := splicing("monitor-api:", cluster, ":", strategyID, ":", now)
	//fmt.Println("APIMapKey:",key)
E
eoLinker API Management 已提交
18 19
	return key
}
Y
Your Name 已提交
20 21 22 23 24

//APIValueKey api value key
func APIValueKey(cluster, strategyID string, apiID string, now string) string {
	key := splicing("monitor-value:", cluster, ":", strategyID, ":", apiID, ":", now)
	//fmt.Println("APIValueKey:",key)
E
eoLinker API Management 已提交
25 26 27
	return key
}

Y
Your Name 已提交
28
func splicing(args ...string) string {
E
eoLinker API Management 已提交
29

Y
Your Name 已提交
30 31
	l := 0
	for _, arg := range args {
E
eoLinker API Management 已提交
32

Y
Your Name 已提交
33
		l += len(arg)
E
eoLinker API Management 已提交
34
	}
Y
Your Name 已提交
35 36
	buf := make([]byte, 0, l)
	b := bytes.NewBuffer(buf)
E
eoLinker API Management 已提交
37

Y
Your Name 已提交
38
	for _, arg := range args {
E
eoLinker API Management 已提交
39 40 41
		b.WriteString(arg)
	}
	return b.String()
Y
Your Name 已提交
42
}