maintenance

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package maintenance sweeps expired rows out of operational Postgres tables that would otherwise grow monotonically: oauth_codes, oauth_access_tokens, and sessions. It is the library half of cmd/maintenance and is invoked as a one-shot from host cron / Kamal scheduled task — not as a goroutine in the main server process.

Scope is intentionally narrow: "expired" means expires_at < NOW(). Revoked access tokens that have not yet expired are left alone so a future audit view can surface them; oauth_clients are never touched.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	OAuthCodes        int64
	OAuthAccessTokens int64
	Sessions          int64
}

Result reports how many rows the sweep deleted per table. Callers use it for structured logging and exit-code decisions.

func Run

func Run(ctx context.Context, pool *pgxpool.Pool, logger *slog.Logger) (Result, error)

Run executes the three cleanup queries in series and logs per-table counts. The queries are independent — a failure in one does not roll the others back; the function returns the first error it sees so a scheduled job surfaces it via its exit code.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL