storage

package
v0.0.0-...-3361740 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotSupported is thrown when the backend store is not supported
	ErrNotSupported = errors.New("Backend storage not supported.")

	// ErrNotImplemented is thrown when a method is not implemented by the current backend
	ErrNotImplemented = errors.New("Call not implemented in current backend")

	// ErrEntityNotSaved is thrown when an entity can't be save into the backend
	ErrEntityNotSaved = errors.New("Can't save data")

	// ErrEntityNotStore is thrown when an entity isn't store into the backend
	ErrEntityNotStore = errors.New("Not store data")
)

Functions

func GetAnalyticsKey

func GetAnalyticsKey(key string) string

GetAnalyticsKey returns database key for Analytics

func RegisterStorage

func RegisterStorage(name string, f StorageFunc)

Types

type Analytics

type Analytics struct {
	// LongUrlClicks: Number of clicks on all short URLs pointing to
	// this long URL.
	LongURLClicks int64 `json:"longUrlClicks,omitempty,string"`

	// ShortUrlClicks: Number of clicks on this short URL.
	ShortURLClicks int64 `json:"shortUrlClicks,omitempty,string"`

	// UserAgent represents the user agent requester
	//UserAgents []*StringCount   `json:"user_agents,omitempty"`
	UserAgents map[string]int64 `json:"user_agents,omitempty"`
}

Analytics contains click statistics

func NewAnalytics

func NewAnalytics() *Analytics

NewAnalytics creates an Analytics instance

type Storage

type Storage interface {

	// Init initialize the storage
	Init() error

	// Name identify the storage
	Name() string

	// Put a value at the specified key
	Put(key []byte, value []byte) error

	// Get a value given its key
	Get(key []byte) ([]byte, error)

	// Delete the value at the specified key
	Delete(key []byte) error

	// List retrieve all keys
	List() ([][]byte, error)

	// Close the store connection
	Close() error
}

Storage represents the Abraracourcix backend storage Each storage should support every call listed here.

func New

func New(conf *config.Configuration) (Storage, error)

type StorageFunc

type StorageFunc func(conf *config.Configuration) (Storage, error)

type URL

type URL struct {
	// Key is the short URL that expands to the long URL you provided
	Key string `json:"key"`
	// LongURL is the long URL to which it expands.
	LongURL string `json:"url"`
	// CreationDate is the time at which this short URL was created
	CreationDate time.Time `json:"creation_date"`
}

URL represents an URL into storage backend

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL