db

package
v0.0.0-...-802b285 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanDayRecords

func CleanDayRecords(before time.Time)

func CleanHoursRecord

func CleanHoursRecord(before time.Time)

func CleanMonthRecords

func CleanMonthRecords(before time.Time)

func Close

func Close() error

func DoRecord

func DoRecord(user string, rx int64, tx int64, t time.Time) error

DoRecord should be invoked at the begin of the first minute of an hour in order to account the traffic during last hour.

func InitDb

func InitDb(ro bool) error

func SumDay

func SumDay(t time.Time) error

SumDay should be invoked at the first hour of the day, the time value should be the first hour after the day to sum.

func SumMonth

func SumMonth(t time.Time) error

SumMonth Should be invoked at the first day of a month, the time value should be the first day after the month to sum.

func UserCount

func UserCount() int

Types

type Record

type Record struct {
	User string `json:"user"`
	Rx   int64  `json:"rx"`
	Tx   int64  `json:"tx"`
}

func QueryDay

func QueryDay(t time.Time) []Record

func QueryDaySum

func QueryDaySum(month time.Time) []Record

func QueryHourSum

func QueryHourSum(day time.Time) []Record

func QueryMonth

func QueryMonth(t time.Time) []Record

Jump to

Keyboard shortcuts

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