sagagc

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package sagagc periodically drives saga retention, deleting executions that have been in a terminal state longer than the retention window.

Saga executions are durable by design: the executor persists one on every state transition so a crashed process can resume or roll back. Nothing ever removed them, so a cluster accumulated one entity per sandbox creation and per build forever, each carrying a JSON blob of every action's output. Garden reached roughly 4,900 in a month of gentle use, and a single app that fails to bind its declared port retries on a loop and writes thousands a day (MIR-1519).

The policy itself lives in pkg/saga, which owns how executions are stored. This package is the schedule: when to sweep, how much to do at once, and what to tell an operator afterwards.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GCConfig

type GCConfig struct {
	// Retention is how long a terminal execution is kept after it finished.
	// Zero disables deletion entirely.
	Retention time.Duration

	// CheckInterval is how often to run a sweep.
	CheckInterval time.Duration

	// MaxDeletesPerSweep caps deletions per sweep so an accumulated backlog
	// drains over several passes. Zero means unbounded.
	MaxDeletesPerSweep int

	// SweepTimeout bounds a single sweep. A truncated sweep is fine; the next
	// one picks up where this left off, since the pass is idempotent.
	SweepTimeout time.Duration
}

GCConfig tunes the retention sweep.

func DefaultGCConfig

func DefaultGCConfig() GCConfig

DefaultGCConfig returns the default configuration. The seven-day retention is what RFD-35 committed to. The per-sweep cap and interval together drain about 48,000 executions a day, comfortably ahead of the worst observed write rate.

type GCController

type GCController struct {
	Log     *slog.Logger
	Storage saga.Storage
	Config  GCConfig
	// contains filtered or unexported fields
}

GCController periodically deletes expired saga executions. It runs on the coordinator, so exactly one process is sweeping and it never contends with runners writing saga state through the entity-access client.

func (*GCController) Start

func (c *GCController) Start(ctx context.Context)

Start begins the periodic sweep.

func (*GCController) Stop

func (c *GCController) Stop()

Stop gracefully stops the controller.

Jump to

Keyboard shortcuts

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