storage

package
v0.0.0-...-c6df4bf Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEFAULT_DATABASE = 0

Functions

This section is empty.

Types

type InMemoryLinksBackend

type InMemoryLinksBackend struct {
	LinkMap map[string]generated.Link
}
func (s InMemoryLinksBackend) CreateOrUpdateLink(entry *generated.Link) error
func (s InMemoryLinksBackend) DeleteLink(shortUrl string) error

func (InMemoryLinksBackend) GetAllLinksPaginated

func (s InMemoryLinksBackend) GetAllLinksPaginated(offset int, pagesize int) (*[]generated.Link, error)

getAllLinksPaginated implements LinksBackend.

func (InMemoryLinksBackend) GetLinkMetadata

func (s InMemoryLinksBackend) GetLinkMetadata(shortUrl string) (link *generated.Link, err error)
func (s InMemoryLinksBackend) GetOwnersLinks(owner string) (links *[]generated.Link, err error)

func (InMemoryLinksBackend) GetOwnersLinksPaginated

func (InMemoryLinksBackend) GetOwnersLinksPaginated(owner string, offset int, pagesize int) (links *[]generated.Link, err error)

getOwnersLinksPaginated implements LinksBackend.

func (s InMemoryLinksBackend) GetTargetLink(url string) (target *string, permanent bool, err error)

func (InMemoryLinksBackend) Start

func (s InMemoryLinksBackend) Start()

type LinksBackend

type LinksBackend interface {
	Start()
	CreateOrUpdateLink(*generated.Link) error
	GetTargetLink(url string) (*string, bool, error)
	GetOwnersLinks(owner string) (*[]generated.Link, error)
	GetOwnersLinksPaginated(owner string, offset int, pagesize int) (*[]generated.Link, error)
	GetAllLinksPaginated(offset int, pagesize int) (*[]generated.Link, error)
	GetLinkMetadata(url string) (*generated.Link, error)
	DeleteLink(url string) error
}

func BuildRedisBackend

func BuildRedisBackend(config RedisConfig) LinksBackend

type PostgresConfig

type PostgresConfig struct {
	Host     string
	User     string
	Password string
	Database string
	Port     string
}

type PostgresLinksBackend

type PostgresLinksBackend struct {
	DB *pgxpool.Pool
}

func BuildPostgresBackend

func BuildPostgresBackend(localConfig PostgresConfig) PostgresLinksBackend
func (s PostgresLinksBackend) CreateOrUpdateLink(entry *generated.Link) error

CreateOrUpdateLink implements LinksBackend.

func (s PostgresLinksBackend) DeleteLink(url string) error

DeleteLink implements LinksBackend.

func (PostgresLinksBackend) GetAllLinksPaginated

func (s PostgresLinksBackend) GetAllLinksPaginated(offset int, pagesize int) (links *[]generated.Link, err error)

GetAllLinksPaginated implements LinksBackend.

func (PostgresLinksBackend) GetLinkMetadata

func (s PostgresLinksBackend) GetLinkMetadata(url string) (link *generated.Link, err error)

GetLinkMetadata implements LinksBackend.

func (s PostgresLinksBackend) GetOwnersLinks(owner string) (links *[]generated.Link, err error)

GetOwnersLinks implements LinksBackend.

func (PostgresLinksBackend) GetOwnersLinksPaginated

func (s PostgresLinksBackend) GetOwnersLinksPaginated(owner string, offset int, pagesize int) (links *[]generated.Link, err error)

GetOwnersLinksPaginated implements LinksBackend.

func (s PostgresLinksBackend) GetTargetLink(url string) (target *string, permanent bool, err error)

GetTargetLink implements LinksBackend.

func (PostgresLinksBackend) Start

func (s PostgresLinksBackend) Start()

type RedisConfig

type RedisConfig struct {
	Host     string
	User     string
	Password string
	Database string
	Port     string
}

type RedisLinksBackend

type RedisLinksBackend struct {
	// contains filtered or unexported fields
}
func (r *RedisLinksBackend) CreateOrUpdateLink(link *generated.Link) error

CreateOrUpdateLink implements LinksBackend.

func (r *RedisLinksBackend) DeleteLink(url string) error

DeleteLink implements LinksBackend.

func (*RedisLinksBackend) GetAllLinksPaginated

func (r *RedisLinksBackend) GetAllLinksPaginated(offset int, pagesize int) (links *[]generated.Link, err error)

GetAllLinksPaginated implements LinksBackend.

func (*RedisLinksBackend) GetLinkMetadata

func (r *RedisLinksBackend) GetLinkMetadata(url string) (link *generated.Link, err error)

GetLinkMetadata implements LinksBackend.

func (r *RedisLinksBackend) GetOwnersLinks(owner string) (links *[]generated.Link, err error)

GetOwnersLinks implements LinksBackend.

func (*RedisLinksBackend) GetOwnersLinksPaginated

func (r *RedisLinksBackend) GetOwnersLinksPaginated(owner string, offset int, pagesize int) (links *[]generated.Link, err error)

GetOwnersLinksPaginated implements LinksBackend.

func (r *RedisLinksBackend) GetTargetLink(url string) (target *string, permanent bool, err error)

GetTargetLink implements LinksBackend.

func (*RedisLinksBackend) Start

func (r *RedisLinksBackend) Start()

Start implements LinksBackend.

Jump to

Keyboard shortcuts

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