package cron

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

Package cron schedules jobs.

Index

Variables

var LastMemstore = func() *lastMemstore {
	l := &lastMemstore{}
	l.Set(ztime.Now())
	return l
}()
var Tasks = []Task{
	{"persist hits", PersistAndStat, 10 * time.Second},
	{"vacuum pageviews (data retention)", DataRetention, 1 * time.Hour},
	{"renew ACME certs", renewACME, 2 * time.Hour},
	{"vacuum soft-deleted sites", vacuumDeleted, 12 * time.Hour},
	{"process scheduled plan changes", cancelPlan, 12 * time.Hour},
	{"rm old exports", oldExports, 1 * time.Hour},
	{"cycle sessions", sessions, 1 * time.Minute},
	{"report usage", reportUsage, 12 * time.Hour},
	{"send email reports", EmailReports, 1 * time.Hour},
}

Functions

func DataRetention

func DataRetention(ctx context.Context) error

func EmailReports

func EmailReports(ctx context.Context) error

EmailReports sends email reports for sites that have this configured.

func PersistAndStat

func PersistAndStat(ctx context.Context) error

func ReindexStats

func ReindexStats(ctx context.Context, site goatcounter.Site, hits []goatcounter.Hit, tables []string) error

ReindexStats re-indexes all the statistics for the given tables; this is intended to be run by the "goatcounter reindex" command.

func RunBackground

func RunBackground(ctx context.Context)

RunBackground runs tasks in the background according to the given schedule.

func UpdateStats

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

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 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.2.2
Published
Feb 16, 2022
Platform
darwin/amd64
Imports
24 packages
Last checked
7 hours ago

Tools for package owners.