service

package
v0.0.0-...-577c64b Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBadInput is error for bad input
	ErrBadInput error
	// ErrInvalidURL is error for invalid URL
	ErrInvalidURL error
	// ErrInsertFailed is error for insert error
	ErrInsertFailed error
	// ErrInvalidUUID is error for invalid UUID
	ErrInvalidUUID error
	// ErrUUIDNotFound is error for UUID not found in the DB
	ErrUUIDNotFound error
)

Functions

func Generator

func Generator(longURL string) (shortURL string, err error)

Generator cretes and stores URLs

func Health

func Health() (status bool, err error)

Health checks if everything's fine

func Hits

func Hits(uuid string) (daily, weekly, total int64, err error)

Hits returns number hits of a shortUrl

func Redirect

func Redirect(uuid string) (longURL string, err error)

Redirect retrieves long URL from the DB.

func SetConfig

func SetConfig(cfg configuration.Config)

SetConfig sets the config from main

func SetDatabaseInterface

func SetDatabaseInterface(dBase Database)

SetDatabaseInterface sets DB interface

Types

type Database

type Database interface {
	Health() (status bool, err error)
	InsertURL(uuid, longURL string) (err error)
	LongURL(uuid string) (longURL string, err error)
	InsertHit(uuid string) (err error)
	Hits(uuid string) (daily, weekly, total int64, err error)
}

Database is DB interface

Jump to

Keyboard shortcuts

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