utils

package
v0.0.0-...-0af0ada Latest Latest
Warning

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

Go to latest
Published: May 29, 2016 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789"
	BASE     = int64(len(ALPHABET))
)

Variables

View Source
var (
	NewKey chan string
)
View Source
var (
	ShortUrls chan string
)

Functions

func Decode

func Decode(s string) int64

func Encode

func Encode(i int64) string

func GenerateKeys

func GenerateKeys()

Creates a buffered channel which holds 32 uuid's The goroutine is non-blocking as long as the channel is not full

func Shortener

func Shortener()

Types

type Configuration

type Configuration struct {
	Redis RedisConf
	Stats Stats
	Web   WebConf
}

type RedisConf

type RedisConf struct {
	Pool *redis.Pool
	Host string
}

func NewFactory

func NewFactory(host string) *RedisConf

func (*RedisConf) ActivateUser

func (conf *RedisConf) ActivateUser(key string)

func (*RedisConf) Add

func (conf *RedisConf) Add(item *ShortenedURL) (err error)

func (*RedisConf) Decode

func (conf *RedisConf) Decode(b []byte, v interface{}) error

func (*RedisConf) Delete

func (conf *RedisConf) Delete(key string) (bool, error)

func (*RedisConf) Encode

func (conf *RedisConf) Encode(v interface{}) ([]byte, error)

func (*RedisConf) Exists

func (conf *RedisConf) Exists(key string) (bool, error)

func (*RedisConf) Get

func (conf *RedisConf) Get(key string, e interface{}) (interface{}, error)

func (*RedisConf) LPush

func (conf *RedisConf) LPush(key string, val ...string) (int64, error)

Adds an element as the last element of the set

func (*RedisConf) NewPool

func (conf *RedisConf) NewPool() *redis.Pool

func (*RedisConf) RPush

func (conf *RedisConf) RPush(key string, val ...string) (int64, error)

Adds an element infront of the others stored in the set

type ShortenedURL

type ShortenedURL struct {
	Key     string
	Expires float64
	Url     string
}

type Stats

type Stats struct {
	Enabled           bool
	TotalUrlsKey      string
	TotalRedirectsKey string
}

type User

type User struct {
	Key     string
	Expires float64
}

type WebConf

type WebConf struct {
	Base string
	Port uint16
}

Jump to

Keyboard shortcuts

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