db

package
v0.0.0-...-6251ae7 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2022 License: AGPL-3.0 Imports: 18 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 struct {
	// contains filtered or unexported fields
}

DB provides high level query execution over a PGX connection pool.

func New

func New(ctx context.Context, dsn string) (*DB, error)

New configures a new PGX connection pool with a zerolog adapter taken from context.

func Wrap

func Wrap(pool *pgxpool.Pool) *DB

func (*DB) Close

func (db *DB) Close()

func (*DB) CountDailyMethodTotals

func (db *DB) CountDailyMethodTotals(ctx context.Context, start, end time.Time) ([]*countv1.MethodCount, error)

CountDailyMethodTotals deletes entries from count.requests for the given day. Deleted entries are counted for each method and path pair and inserted in the count.daily_method_totals table. The resulting count enties are returned.

func (*DB) GetPeriodTotals

func (db *DB) GetPeriodTotals(ctx context.Context, start, end time.Time) ([]*countv1.MethodCount, error)

GetPeriodTotals selects entries from count.daily_method_totals and sums the totals columns, grouped by method and path. Start and end times are inclusive.

func (*DB) InsertMethodRequest

func (db *DB) InsertMethodRequest(ctx context.Context, method countv1.Method, path string, requestTS time.Time) error

InsertMethodRequest inserts a request for a certain method and path. Inserts are retried untill the operation succeeds without error or when the passed context expires.

func (*DB) ListDailyTotals

func (db *DB) ListDailyTotals(ctx context.Context, start, end time.Time) ([]*countv1.MethodCount, error)

ListDailyTotals selects entries from count.daily_method_totals in the date interval of start-end inclusive.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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