storage

package
v0.0.0-...-c64dc89 Latest Latest
Warning

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

Go to latest
Published: May 28, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorUserNotFound  = errors.New("user with given username doesn't exist")
	ErrorUserDuplicate = errors.New("user with given username already exists")

	ErrorMaxUrlCount = errors.New("user reached max url count")
)

Functions

This section is empty.

Types

type Alert

type Alert interface {
	GetAlerts(context.Context, string, string) ([]model.Alert, error)
}

type LocalWorker

type LocalWorker interface {
	GetUrlsToCall() ([]model.Url, error)
	SaveAlert(int64, uint) error
	SaveCallResults([]model.CallUrlResult) error
}

type PostgresDB

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

func NewPostgresDBStorage

func NewPostgresDBStorage(db *gorm.DB) *PostgresDB

func (*PostgresDB) GetAlerts

func (p *PostgresDB) GetAlerts(ctx context.Context, urlName string, username string) ([]model.Alert, error)

func (*PostgresDB) GetUrlStats

func (p *PostgresDB) GetUrlStats(ctx context.Context, urlName string, username string) ([]model.Call, error)

func (*PostgresDB) GetUrlsToCall

func (p *PostgresDB) GetUrlsToCall() ([]model.Url, error)

func (*PostgresDB) GetUserUrls

func (p *PostgresDB) GetUserUrls(ctx context.Context, username string) ([]model.Url, error)

func (*PostgresDB) LoadByUserPass

func (p *PostgresDB) LoadByUserPass(ctx context.Context, username string, password string) (*model.User, error)

func (*PostgresDB) SaveAlert

func (p *PostgresDB) SaveAlert(time int64, urlId uint) error

func (*PostgresDB) SaveCallResults

func (p *PostgresDB) SaveCallResults(callResults []model.CallUrlResult) error

func (*PostgresDB) SaveUrl

func (p *PostgresDB) SaveUrl(ctx context.Context, req *request.Url, username string) (*model.Url, error)

func (*PostgresDB) SaveUser

func (p *PostgresDB) SaveUser(ctx context.Context, req *request.User) (*model.User, error)

type Url

type Url interface {
	SaveUrl(context.Context, *request.Url, string) (*model.Url, error)
	GetUserUrls(context.Context, string) ([]model.Url, error)
	GetUrlStats(context.Context, string, string) ([]model.Call, error)
}

type User

type User interface {
	SaveUser(context.Context, *request.User) (*model.User, error)
	LoadByUserPass(context.Context, string, string) (*model.User, error)
}

Jump to

Keyboard shortcuts

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