Documentation
¶
Overview ¶
Package gc reconciles the object store against the metadata table. It runs as a background sweep, never on the request path, and is a sibling use-case to the files service: it orchestrates storage + metadata but imports neither api nor files.
Each sweep does two jobs:
- Purge soft-deleted rows — delete the object, then hard-delete the row.
- Reclaim orphans — objects in the store with no backing row (e.g. a write whose metadata commit never landed because the process died) are deleted once older than the grace period.
The grace period is the safety valve: an in-flight upload writes the object before committing its row, so a just-written object briefly looks orphaned. Only objects older than the grace period are reclaimed, so a valid upload in progress is never destroyed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector runs the reconciliation sweep.
func New ¶
func New(store Store, repo Repo, log *slog.Logger, interval, grace, idemTTL time.Duration) *Collector
New constructs a Collector. idemTTL is the idempotency-key retention; a non-positive value disables key expiry.
func (*Collector) OnSweep ¶ added in v1.1.0
OnSweep registers fn to observe every sweep's outcome. The composition root wires metrics through it, so this package stays instrumentation-free. Call it before Run; it is not safe to change while the collector is running.
type Repo ¶
type Repo interface {
ListDeleted(ctx context.Context, limit int) ([]*metadata.File, error)
Purge(ctx context.Context, id string) error
StorageKeys(ctx context.Context) (map[string]struct{}, error)
PurgeIdempotencyKeys(ctx context.Context, before time.Time) (int, error)
}
Repo is the slice of metadata.Repository the collector needs.