gc

package
v0.2.49 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: GPL-2.0, GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package gc implements the blob garbage collector for the checkpoint subsystem. It periodically sweeps orphaned blobs that are no longer referenced by any chat's event log.

Index

Constants

View Source
const BlobGCMinAge = 5 * time.Minute

BlobGCMinAge is the minimum age a blob must have before it's eligible for collection.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlobRefer

type BlobRefer interface {
	ReferencedBlobs(ctx context.Context) []string
}

BlobRefer returns the set of blob SHAs referenced by a single chat's event log. The checkpoint.Manager type satisfies this interface.

type Coordinator

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

Coordinator manages the blob GC goroutine lifecycle. One instance per Store; constructed at Store creation time.

func NewCoordinator

func NewCoordinator(configDir, blobsDir, chatsDir, eventsFile string, interval time.Duration, _ *sync.RWMutex, cached func() map[string]BlobRefer) *Coordinator

NewCoordinator builds a Coordinator. cached returns the current set of cached managers (for the fast-path collection phase). The 5-minute blob age gate (blobGCMinAge) provides the primary safety guarantee against removing in-flight blobs; no per-sweep lock is needed.

func (*Coordinator) RunOnce

func (gc *Coordinator) RunOnce(ctx context.Context)

RunOnce runs one GC sweep. Exported for test access.

func (*Coordinator) RunOnceWithCounts

func (gc *Coordinator) RunOnceWithCounts(ctx context.Context) (removed, scanned int, err error)

RunOnceWithCounts runs one GC sweep and returns the counts. Used by tests that need to verify exact removal counts.

func (*Coordinator) Start

func (gc *Coordinator) Start(ctx context.Context)

Start kicks off the periodic blob GC. Runs one immediate sweep, then every interval. Idempotent — a second call while a loop is already running is a no-op.

func (*Coordinator) Stop

func (gc *Coordinator) Stop()

Stop halts the background GC goroutine and waits for it to finish. Safe to call even if Start was never invoked.

Jump to

Keyboard shortcuts

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