hexcrc32.go 859 B

12345678910111213141516171819202122232425262728293031323334
  1. package strategy
  2. import (
  3. "errors"
  4. "code.osinet.fr/fgm/kurz/storage"
  5. "code.osinet.fr/fgm/kurz/url"
  6. )
  7. /*
  8. HexCrc32Strategy is a legacy AliasingStrategy : hex dump for crc32 hash of source URL.
  9. - Pros :
  10. - URLs are easy to communicate over the phone, especially to programmers, even in poor sound conditions.
  11. - Cons :
  12. - They are rather long
  13. - Does not handle collisions: first come, first serve. Later entries are simply rejected.
  14. */
  15. type HexCrc32Strategy struct {
  16. base baseStrategy
  17. }
  18. func (y HexCrc32Strategy) Name() string {
  19. return "hexCrc32"
  20. }
  21. func (y HexCrc32Strategy) Alias(short *url.LongUrl, s storage.Storage, options ...interface{}) (url.ShortUrl, error) {
  22. var ret url.ShortUrl
  23. return ret, errors.New("HexCrc32 not implemented yet")
  24. }
  25. func (y HexCrc32Strategy) UseCount(s storage.Storage) int {
  26. return y.base.UseCount(s)
  27. }