gc

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Cross-module GC protocols: snapshots opt in via the matching method; this file imports nothing concrete.

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. Returns nil if the snapshot does not 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. Returns nil if the snapshot does not implement ActiveVMIDs.

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 returns IDs to delete; others holds snapshots from peer modules (cast for cross-module analysis, e.g. VMs pinning images).
	Resolve func(ctx context.Context, 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, 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

func (*Orchestrator) Run

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

Run executes one GC cycle: lock all → snapshot → resolve → collect. Fail-closed on busy locks to keep cross-module decisions consistent.

Jump to

Keyboard shortcuts

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