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 ¶
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.