* stats: pass configuration object via stats.New()

This commit is contained in:
Simon Zolin
2019-09-16 16:14:52 +03:00
parent 3862662201
commit b8a98c1a77
4 changed files with 44 additions and 30 deletions

View File

@@ -8,12 +8,16 @@ import (
type unitIDCallback func() uint32
// Config - module configuration
type Config struct {
Filename string // database file name
LimitDays uint32 // time limit (in days)
UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used.
}
// New - create object
// filename: DB file name
// limit: time limit (in days)
// unitID: user function to get the current unit ID. If nil, the current time hour is used.
func New(filename string, limit uint32, unitID unitIDCallback) (Stats, error) {
return createObject(filename, limit, unitID)
func New(conf Config) (Stats, error) {
return createObject(conf)
}
// Stats - main interface