Documentation ¶
Overview ¶
Package shorturl provides functionality for the basic CRUD operations.
Index ¶
Constants ¶
View Source
const (
// KindName is the datastore kind name for short url.
KindName = "ShortUrl"
)
Variables ¶
View Source
var ( // ErrDatastoreInconsistent is returned when the datastore is in an // Inconsistent state. Typical example would be when the memcache // indicates that there should've been an instance of the short URL // stored but the actual instance cannot be found. ErrDatastoreInconsistent = errors.New("Datastore Inconsistent") ErrDatastoreWriteDisabled = errors.New("Datastore write disabled") // ErrNotFound is the error to be raised when the short URL matching the // search criteria cannot be found ErrNotFound = errors.New("Short URL not found") )
Error values
Functions ¶
This section is empty.
Types ¶
type ShortURL ¶
type ShortURL struct { ID int64 `datastore:"-"` Hash string OriginalURL string `datastore:"OriginalUrl,noindex"` }
ShortURL is the entity used for storing short URL. Because of the fact that URLs can be more than 500 characters long and that we cannot index string properties longer than 500 characters directly to ensure uniqueness, we have to use the hash code of the URL as a fallback.
We also use multiple hash algorithms just to eliminate the possibility of hash collisions of one particular hashing algorithm. Using SHA512, SHA1, and MD5 simultaneously should make a hash collision statistically extremely. improbable.
Click to show internal directories.
Click to hide internal directories.