Documentation
¶
Overview ¶
Package retention removes what the platform writes and nothing else ever removes (#1904): soft-deleted portal items past their grace period, with their objects; archived memory records; producer rows whose file is gone; and GraphQL operation embeddings of a schema a connection no longer has. One pass mends rather than removes: it names the portal bucket on asset rows written with none, ahead of the purge, which could not otherwise delete their objects (#1931).
Each sweep runs once a day under its own PostgreSQL advisory lock, so every replica may run the loop and only one of them deletes at a time, and one subsystem's sweep never waits on another's. The first pass runs at start rather than a day later, so a deployment that lowers a retention restarts into it.
Index ¶
Constants ¶
const ( DefaultDeletedRetentionDays = 30 DefaultArchivedRetentionDays = 90 DefaultProducerRetentionDays = 90 )
Retention defaults, in days. A deleted portal item is kept a month so a mistaken delete can still be taken up with an administrator; the others match the call catalog's and the audit log's ninety days.
const DefaultInterval = 24 * time.Hour
DefaultInterval is how often the sweeps run.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
DB *sql.DB
// Objects deletes the portal's stored objects; nil deletes rows only.
Objects portalpurge.ObjectDeleter
// Bucket is the portal bucket, where collection mosaics are stored.
Bucket string
// Portal is false where the portal is off, which purges nothing of it.
Portal bool
DeletedDays, ArchivedDays, ProducerDays int
Every time.Duration
}
Config is what Assemble builds the sweeps from. Each *Days is already resolved by Days: 0 turns its sweep off.
type Loop ¶
type Loop struct {
// contains filtered or unexported fields
}
Loop runs a set of sweeps on an interval until Close.
func Assemble ¶
Assemble builds the loop over every sweep cfg turns on. It is nil without a database.
func (*Loop) RunOnce ¶
RunOnce runs every sweep once, each under its lock and as its own unit of work, reported under "retention_" + the sweep's name: a sweep another replica is running is counted as skipped, the rows one removed as purged, and one that fails is logged, returned joined with the others' failures, and does not stop them.
type Sweep ¶
Sweep is one removal the loop runs. LockKey is its advisory lock, distinct from every other maintenance lock in the platform. Run reports how many rows it removed.
func AssetBucket ¶ added in v1.137.1
AssetBucket is the pass that names the portal bucket on asset rows an early release wrote with none (#1931); see assetbucket. It removes nothing, so it reports nothing to the loop and logs what it wrote itself. Nothing without a portal bucket.
func MemoryArchived ¶
MemoryArchived is the sweep that deletes memory records archived more than days ago. Nothing when days is 0.
func OrphanedProducers ¶
OrphanedProducers is the sweep that deletes producer rows whose file is gone. Nothing when days is 0.
func PortalDeleted ¶
func PortalDeleted(p *portalpurge.Purger, days int) []Sweep
PortalDeleted is the sweep that purges portal items deleted more than days ago, with their objects. Nothing when days is 0.
func SupersededGraphQL ¶
SupersededGraphQL is the sweep that deletes embeddings of superseded GraphQL schemas. It takes no age: a superseded schema's vectors are never read again.