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
- func Days(configured, def int) int
- type Config
- type Loop
- type Sweep
- func AssetBucket(db *sql.DB, bucket string) []Sweep
- func BotCheckAnswers(db *sql.DB) []Sweep
- func CollectionItems(remove func(ctx context.Context) (int64, error)) []Sweep
- func EndpointFailures(db *sql.DB) []Sweep
- func EndpointRefusals(db *sql.DB) []Sweep
- func ExpiredCallTasks(db *sql.DB) []Sweep
- func MemoryArchived(db *sql.DB, days int) []Sweep
- func OrphanedProducers(db *sql.DB, days int) []Sweep
- func PortalDeleted(p *portalpurge.Purger, days int) []Sweep
- func ScriptTokenUses(db *sql.DB) []Sweep
- func SupersededGraphQL(db *sql.DB) []Sweep
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) Add ¶ added in v1.166.4
Add appends sweeps a layer assembled after the loop was built (the collection item sweep needs the portal's authorization core, #2752). Every added sweep runs in the process's first pass, whenever it is added (#2757): one added before that pass has read the sweeps is in it, and one added after is run at once, beside it, so a replica that restarts more often than the interval still runs it. A sweep added to a loop Start found empty starts the loop.
func (*Loop) Close ¶
Close stops the loop and waits for a running pass, and any added sweeps running beside it, to return.
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 BotCheckAnswers ¶ added in v1.148.0
BotCheckAnswers is the sweep that deletes answered bot check challenges (#2173) whose challenge can no longer be answered, so a replay of one is refused by its expiry instead.
func CollectionItems ¶ added in v1.166.4
CollectionItems is the sweep that removes from each collection the items its owner cannot open (#2752), run by remove. Nothing without one.
func EndpointFailures ¶ added in v1.148.0
EndpointFailures is the sweep that deletes the failed endpoint requests kept for their script's owner (#2172) once they are older than epbinding.FailureRetention.
func EndpointRefusals ¶ added in v1.149.0
EndpointRefusals is the sweep that deletes the counts of requests an endpoint refused (#2208) once their hour is older than eprefusal.Retention.
func ExpiredCallTasks ¶ added in v1.143.0
ExpiredCallTasks is the sweep that deletes call tasks past their expiry. It takes no age of its own: each row carries the one it was created with.
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 ScriptTokenUses ¶ added in v1.148.0
ScriptTokenUses is the sweep that deletes the uses of single-use script tokens (#2175) that have expired, so a second use is refused by the token's expiry instead.
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.