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{
	{"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},
}

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 PersistInterval

func PersistInterval(d time.Duration)

func RunBackground

func RunBackground(ctx context.Context)

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

func Stop

func Stop(ctx context.Context) error

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 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.3.0
Published
Oct 17, 2022
Platform
darwin/amd64
Imports
23 packages
Last checked
7 hours ago

Tools for package owners.