suspend

package
v0.41.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package suspend is the room-broker's suspend trigger (v2 warm-sandboxes design §6, owner decision 2026-10-16): a suspendable run in an attended room that waits on an approval while the room stays idle is suspended, and resumed once nothing waits. It acts only through the run's suspend annotations, under the claim's resourceVersion, and mints nothing: the composition deletes and recreates the pod, and the resumed bridge answers the confirmation.

Index

Constants

View Source
const (
	ModeSuspended = "Suspended"
	ModeRunning   = "Running"
)

The operating modes the composition reads.

Variables

This section is empty.

Functions

func Decide

func Decide(after time.Duration, run runwatch.Run, waiting bool, idleSince, now time.Time) (map[string]string, bool)

Decide is the patch of run's annotations, if any. A Running run that waits on an approval in a room idle since idleSince for at least after is suspended, with the running time it has left; a suspended one whose approvals are all closed is resumed, and the resume time recorded. Anything else, a run that is not suspendable or no longer live included, is left alone.

Types

type Suspender

type Suspender struct {
	// Kind is the runs kind, required: the claims patched are its.
	Kind      runwatch.Kind
	Client    patcher
	Approvals approvals
	// After is how long a room stays idle, with a run waiting, before the run is suspended.
	After time.Duration
	// Now is the clock; nil means time.Now.
	Now func() time.Time
	// Log records each suspend and resume; nil discards them.
	Log *slog.Logger
}

Suspender applies Decide to a room's runs.

func (*Suspender) Room

func (s *Suspender) Room(ctx context.Context, room *v1alpha1.Room, idleSince time.Time, runs []runwatch.Run) error

Room suspends or resumes each of runs, the runs of room, whose log last moved at idleSince. An unattended room is never touched: nobody is expected there. A run whose claim moved since it was read is skipped, with the conflict returned, and decided again at the next resync.

Jump to

Keyboard shortcuts

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