Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BlobIDs ¶
BlobIDs extracts blob hex IDs from a snapshot. Returns nil if the snapshot does not implement UsedBlobIDs.
func Collect ¶
Collect aggregates ID sets from all snapshots in others using the given accessor. Snapshots that don't support the accessor return nil and are silently skipped.
Usage:
blobIDs := gc.Collect(others, gc.BlobIDs) vmIDs := gc.Collect(others, gc.VMIDs)
func Register ¶
func Register[S any](o *Orchestrator, m Module[S])
Register adds a typed Module to the Orchestrator. This is a package-level function (not a method) because Go methods cannot have type parameters.
Types ¶
type Module ¶
type Module[S any] struct { Name string Locker lock.Locker // ReadDB reads the module's current state (called while the lock is held). ReadDB func(ctx context.Context) (S, error) // Resolve analyses this module's typed snapshot and returns IDs to delete. // others contains snapshots from all other modules (typed as any). // Use type assertions on others for cross-module analysis (e.g. vm pinning images). Resolve func(snap S, others map[string]any) []string // Collect removes the given IDs (called while the lock is held). Collect func(ctx context.Context, ids []string) error }
Module[S] describes a typed storage module that participates in GC. S is the snapshot type returned by ReadDB and consumed by Resolve, giving the Resolve implementation full type safety on its own data.
type Orchestrator ¶
type Orchestrator struct {
// contains filtered or unexported fields
}
Orchestrator runs GC across all registered modules.
func (*Orchestrator) Run ¶
func (o *Orchestrator) Run(ctx context.Context) error
Run executes one GC cycle:
- TryLock all modules; skip those whose lock is busy.
- ReadDB each locked module to build a snapshot.
- Resolve deletion targets per module. Each module's Resolve receives all other snapshots (typed as any) for cross-module analysis — e.g., image GC checks UsedBlobIDs from the VM snapshot to protect active blobs.
- Collect targets for each snapshotted module.
- Unlock all (deferred).
All locks are held for the entire cycle so that the snapshot, resolve, and collect phases see a consistent view. GC runs infrequently and executes fast, so the extended lock hold is acceptable.