report

package
v0.12.6 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBeforeLastRun = errors.New("cannot schedule report before last run")
)

Functions

This section is empty.

Types

type DailyUsers

type DailyUsers struct {
	// contains filtered or unexported fields
}

The DailyUsers report is generated once per day at the specified schedule using a sleep-based cron mechanism. When the report is generated an email is sent to the Rotational admins with the report contents.

func NewDailyUsers

func NewDailyUsers(emailer DailyUsersEmailer) (report *DailyUsers, err error)

func (*DailyUsers) LastRun

func (r *DailyUsers) LastRun() time.Time

Get the last time the daily report was run.

func (*DailyUsers) NewAccounts added in v0.7.0

func (r *DailyUsers) NewAccounts(tx *sql.Tx, day sql.NamedArg) (accounts []*emails.NewAccountData, err error)

NewAccounts generates the new accounts report as an additional item to the daily users report. It is kept in a separate function because it does not follow the replicated SQL pattern and so needs to be parallelized for it to be effective.

func (*DailyUsers) NextRun

func (r *DailyUsers) NextRun() time.Time

Get the timestamp that the next report should run (within 15 minutes).

func (*DailyUsers) Report

func (r *DailyUsers) Report() (err error)

Runs the daily users report and emails the admins. If an error is returned from report it is expected to be fatal; all other errors should simply be logged.

func (*DailyUsers) Run

func (r *DailyUsers) Run() error

Run the daily users report tool which checks if it needs to run every 15 minutes (e.g. the poll interval) and if the next run time is after the current time it runs the report, otherwise it continues to sleep.

func (*DailyUsers) Scheduler

func (r *DailyUsers) Scheduler(ts time.Time) (err error)

Scheduler determines if the report needs to be run and if it does, it runs the report and schedules the next run (updating the lastRun timestamp). We expect the ts to be passed in from the ticker at run; but if a zero-valued timestamp is passed in, then the current timestamp is used. If this method returns an error it is assumed to be fatal (e.g. so bad it should shut down the reporting tool).

func (*DailyUsers) Shutdown

func (r *DailyUsers) Shutdown() error

Shutdown the report runner gracefully; this will ensure that a report that is currently being generated will finish before shutting down.

type DailyUsersEmailer

type DailyUsersEmailer interface {
	SendDailyUsers(*emails.DailyUsersData) error
}

Jump to

Keyboard shortcuts

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