util.go 376 B

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