util.go 461 B

123456789101112131415161718
  1. package dao
  2. import (
  3. "fmt"
  4. "strconv"
  5. "github.com/dgryski/go-farm"
  6. )
  7. func rangeKey(prefix string, start, end int64) (string, string) {
  8. return prefix + strconv.FormatInt(start, 10), prefix + strconv.FormatInt(end, 10)
  9. }
  10. func keyPrefix(serviceName, operationName string) string {
  11. serviceNameHash := farm.Hash32([]byte(serviceName))
  12. operationNameHash := farm.Hash32([]byte(operationName))
  13. return fmt.Sprintf("%x%x", serviceNameHash, operationNameHash)
  14. }