Documentation ¶
Index ¶
- type DB
- func (db *DB) Close()
- func (db *DB) CountDailyMethodTotals(ctx context.Context, start, end time.Time) ([]*countv1.MethodCount, error)
- func (db *DB) GetPeriodTotals(ctx context.Context, start, end time.Time) ([]*countv1.MethodCount, error)
- func (db *DB) InsertMethodRequest(ctx context.Context, method countv1.Method, path string, requestTS time.Time) error
- func (db *DB) ListDailyTotals(ctx context.Context, start, end time.Time) ([]*countv1.MethodCount, error)
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 (*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.