package cron

import "zgo.at/goatcounter/v2/cron"

Package cron schedules jobs.

Index

Variables

var Tasks = []Task{
	{"vacuum pageviews (data retention)", dataRetention, 1 * time.Hour},
	{"renew ACME certs", renewACME, 2 * time.Hour},
	{"vacuum soft-deleted sites", vacuumDeleted, 12 * time.Hour},
	{"rm old exports", oldExports, 1 * time.Hour},
	{"cycle sessions", sessions, 1 * time.Minute},
	{"send email reports", emailReports, 1 * time.Hour},
	{"persist hits", persistAndStat, time.Duration(persistInterval.Load())},
}

Functions

func SetPersistInterval

func SetPersistInterval(d time.Duration)

func Start

func Start(ctx context.Context)

Start running tasks in the background.

func Stop

func Stop() error

func TaskACME

func TaskACME() error

func TaskDataRetention

func TaskDataRetention() error

func TaskEmailReports

func TaskEmailReports() error

func TaskOldExports

func TaskOldExports() error

func TaskPersistAndStat

func TaskPersistAndStat() error

func TaskSessions

func TaskSessions() error

func TaskVacuumOldSites

func TaskVacuumOldSites() error

func UpdateStats

func UpdateStats(ctx context.Context, site *goatcounter.Site, siteID int64, hits []goatcounter.Hit) error

UpdateStats updates all the stats tables.

Exported for tests.

func WaitACME

func WaitACME()

func WaitDataRetention

func WaitDataRetention()

func WaitEmailReports

func WaitEmailReports()

func WaitOldExports

func WaitOldExports()

func WaitPersistAndStat

func WaitPersistAndStat()

func WaitSessions

func WaitSessions()

func WaitVacuumOldSites

func WaitVacuumOldSites()

Types

type Task

type Task struct {
	Desc   string
	Fun    func(context.Context) error
	Period time.Duration
}

func (Task) ID

func (t Task) ID() string

Source Files

browser_stat.go campaign_stat.go cron.go email_reports.go hit_count.go hit_stat.go language_stat.go location_stat.go ref_count.go size_stat.go system_stat.go tasks.go

Version
v2.5.0 (latest)
Published
Dec 14, 2023
Platform
linux/amd64
Imports
25 packages
Last checked
1 day ago

Tools for package owners.