util.go 318 B

12345678910111213141516171819202122
  1. package cache
  2. import "strings"
  3. const keySeparator = ","
  4. func TotalWeights(c []NodeConf) int {
  5. var weights int
  6. for _, node := range c {
  7. if node.Weight < 0 {
  8. node.Weight = 0
  9. }
  10. weights += node.Weight
  11. }
  12. return weights
  13. }
  14. func formatKeys(keys []string) string {
  15. return strings.Join(keys, keySeparator)
  16. }