stores

package
v0.0.0-...-4507c00 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package stores provides support to interact with the entries

Index

Constants

This section is empty.

Variables

View Source
var ErrEntryIsExpired = errors.New("entry is expired")

ErrEntryIsExpired is returned when the entry is expired

View Source
var ErrGeneratingIDFailed = errors.New("could not generate unique id, all ten tries failed")

ErrGeneratingIDFailed is returned when the 10 tries to generate an id failed

View Source
var ErrNoValidURL = errors.New("the given URL is no valid URL")

ErrNoValidURL is returned when the URL is not valid

Functions

This section is empty.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store holds internal funcs and vars about the store

func New

func New() (*Store, error)

New initializes the store with the db

func (*Store) Close

func (s *Store) Close() error

Close closes the bolt db database

func (*Store) CreateEntry

func (s *Store) CreateEntry(entry shared.Entry, givenID, password string) (string, []byte, error)

CreateEntry creates a new record and returns his short id

func (*Store) DeleteEntry

func (s *Store) DeleteEntry(id string, givenHmac []byte) error

DeleteEntry deletes an Entry fully from the DB

func (*Store) GetEntryAndIncrease

func (s *Store) GetEntryAndIncrease(id string) (*shared.Entry, error)

GetEntryAndIncrease Increases the visitor count, checks if the URL is expired and returns the origin URL

func (*Store) GetEntryByID

func (s *Store) GetEntryByID(id string) (*shared.Entry, error)

GetEntryByID returns a unmarshalled entry of the db by a given ID

func (*Store) GetUserEntries

func (s *Store) GetUserEntries(oAuthProvider, oAuthID string) (map[string]shared.Entry, error)

GetUserEntries returns all the shorted URL entries of an user

func (*Store) GetVisitors

func (s *Store) GetVisitors(id string) ([]shared.Visitor, error)

GetVisitors returns all the visits of a shorted URL

func (*Store) RegisterVisit

func (s *Store) RegisterVisit(id string, visitor shared.Visitor)

RegisterVisit registers an new incoming request in the store

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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