gc

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package gc runs modular garbage collection: recovery precedes discovery, snapshots are loose, and every destructive decision is revalidated by the module under its own entity locks and tombstone leases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlobIDs

func BlobIDs(snap any) map[string]struct{}

BlobIDs extracts blob hex IDs from a snapshot; nil if it doesn't implement UsedBlobIDs.

func Collect

func Collect(others map[string]any, accessor func(any) map[string]struct{}) map[string]struct{}

Collect aggregates ID sets from snapshots via accessor; snapshots that don't implement it are skipped.

func Register

func Register[S any](o *Orchestrator, m Module[S])

Register is package-level because Go methods can't have type params.

func VMIDs

func VMIDs(snap any) map[string]struct{}

VMIDs extracts active VM IDs from a snapshot; nil if it doesn't implement ActiveVMIDs.

Types

type Module

type Module[S any] struct {
	Name string

	// Recover resumes existing tombstones by phase before discovery, so a deleting entry whose data is already gone never reappears as a candidate. Optional.
	Recover func(ctx context.Context) []error

	// ReadDB reads the module's current state (self-locking snapshot).
	ReadDB func(ctx context.Context) (S, error)

	// Resolve returns IDs to delete; others holds snapshots from peer modules (cross-module analysis, e.g. VMs pinning images). Loose: collectors revalidate per candidate.
	Resolve func(ctx context.Context, snap S, others map[string]any) []string

	// Collect removes the given IDs, revalidating each under its entity lock and tombstone lease.
	Collect func(ctx context.Context, ids []string, snap S) error
}

Module[S] is a typed GC participant; S is the snapshot type ReadDB returns and Resolve consumes.

type Orchestrator

type Orchestrator struct {
	// contains filtered or unexported fields
}

Orchestrator runs GC across all registered modules.

func New

func New() *Orchestrator

New returns an Orchestrator with no registered modules.

func (*Orchestrator) Run

func (o *Orchestrator) Run(ctx context.Context) error

Run executes one GC cycle: recover tombstones by phase, then snapshot → resolve → collect; modules revalidate every destructive decision under their own entity locks (§5 loose-snapshot rule).

Jump to

Keyboard shortcuts

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