db

package
v0.0.0-...-6c45f4e Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	Open() error
	Ping() error
	CreateTable() error
	GetMaxIP() (uint32, error)
	GetOldestIP() (uint32, error)
	Save(types.Tasks) error
	Close() error
}

DB implements interface for database (Postgres initially)

type Postgres

type Postgres struct {
	DBAddr, DBPort, DBName, DBUsername, DBPassword, DBTable string
	// contains filtered or unexported fields
}

Postgres contains connection to Postgres

func (*Postgres) Close

func (db *Postgres) Close() error

Close closes connection to DB

func (*Postgres) CreateTable

func (db *Postgres) CreateTable() (err error)

CreateTable creates table if not exists

func (*Postgres) DropTable

func (db *Postgres) DropTable() (err error)

DropTable drops table (for tests)

func (*Postgres) GetMaxIP

func (db *Postgres) GetMaxIP() (maxIP uint32, err error)

GetMaxIP return maximum IP in db

func (*Postgres) GetOldestIP

func (db *Postgres) GetOldestIP() (oldestIP uint32, err error)

GetOldestIP returns oldest IP from db

func (*Postgres) Open

func (db *Postgres) Open() (err error)

Open opens db connection

func (*Postgres) Ping

func (db *Postgres) Ping() error

Ping checks connection to db

func (*Postgres) Save

func (db *Postgres) Save(results types.Tasks) (err error)

Save commits information to db

Jump to

Keyboard shortcuts

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