github.com/lingyao2333/mo-zero@v1.4.1/core/stores/cache/util.go (about) 1 package cache 2 3 import "strings" 4 5 const keySeparator = "," 6 7 // TotalWeights returns the total weights of given nodes. 8 func TotalWeights(c []NodeConf) int { 9 var weights int 10 11 for _, node := range c { 12 if node.Weight < 0 { 13 node.Weight = 0 14 } 15 weights += node.Weight 16 } 17 18 return weights 19 } 20 21 func formatKeys(keys []string) string { 22 return strings.Join(keys, keySeparator) 23 }