Documentation ¶
Overview ¶
Package storages allows multiple implementation on how to store URLs as shorter names and retrieve them later.
Index ¶
- Variables
- func CleanPath(path string) string
- func FlattenPath(path string, separator string) string
- type Filesystem
- type Inmem
- func (s *Inmem) Load(ctx context.Context, rawShort string) (string, error)
- func (s *Inmem) SaveName(ctx context.Context, rawShort string, url string) error
- func (s *Inmem) Search(ctx context.Context, searchTerm string) ([]SearchResult, error)
- func (s *Inmem) String() string
- func (s *Inmem) TopNForPeriod(ctx context.Context, n int, days int) ([]TopNResult, error)
- type NamedStorage
- type Postgres
- func (p *Postgres) Load(ctx context.Context, rawShort string) (string, error)
- func (p *Postgres) SaveName(ctx context.Context, rawShort string, url string) error
- func (p *Postgres) Search(ctx context.Context, searchTerm string) ([]SearchResult, error)
- func (p *Postgres) TopNForPeriod(ctx context.Context, n int, days int) ([]TopNResult, error)
- type Regex
- type S3
- type SearchResult
- type SearchableStorage
- type Storage
- type TopN
- type TopNResult
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrURLEmpty = errors.New("provided URL is of zero length") ErrShortEmpty = errors.New("provided short name is of zero length") ErrURLNotAbsolute = errors.New("provided URL is not an absolute URL") ErrShortNotSet = errors.New("storage layer doens't have a URL for that short code") ErrFuzzyMatchFound = errors.New("fuzzy match found") )
Functions ¶
func FlattenPath ¶
Takes a possibly multilevel path and flattens it by dropping any slashes
Types ¶
type Filesystem ¶
type Filesystem struct { Root string // contains filtered or unexported fields }
func NewFilesystem ¶
func NewFilesystem(root string) (*Filesystem, error)
type Inmem ¶
type Inmem struct { RandLength int // contains filtered or unexported fields }
func NewInmemFromMap ¶
func (*Inmem) TopNForPeriod ¶
type NamedStorage ¶
type Postgres ¶
type Postgres struct {
// contains filtered or unexported fields
}
func NewPostgres ¶
func (*Postgres) TopNForPeriod ¶
type SearchResult ¶
type SearchableStorage ¶
type TopNResult ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.