allocator

package
v0.3.0-20260820034428-... Latest Latest
Warning

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

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

README

allocator

The allocator package defines a composition point used by the standard Speculator: an Allocator spends the queue's build budget over a candidate iterator. Like generator, it is not a controller-facing extension — an alternate Speculator need not use or expose this split — so there is no Config or Factory here; an Allocator is chosen when the standard Speculator is constructed.

Allocate pulls candidates in the order the iterator yields them and matches them against the queue's current path sets by path ID. A pending or building path keeps the slot it already holds rather than starting a second attempt. A path whose build already finished comes back round as a candidate — the generator enumerates the whole space — and is skipped. Neither draws on free budget.

Pending, building, and cancelling paths all charge the budget; a cancelling build holds its slot until it reaches a terminal state. Terminal paths charge nothing. Allocate returns the build and cancel actions that spend what is left.

A cancelled or expired context aborts the run with its error and no actions. The output is all-or-nothing on purpose: a partial list would fund an arbitrary prefix of the ranking, leaving the budget half-spent on whatever was pulled first.

Because cancellation is best-effort, an Allocator should not spend capacity it only expects a cancel to release. A build cancelled to make room keeps charging the budget until that cancel reaches a terminal state, so the queue converges over successive runs instead of oversubscribing the hard cap in one pass.

How the budget is measured is the implementation's choice. The simplest unit is a build: every path costs one slot, whatever its build does. An Allocator that understands build size — target count, historical cost — could weight paths instead and pack the budget more tightly.

Documentation

Overview

Package allocator defines the budget-spending composition point used by the standard Speculator. An Allocator spends the queue's build budget over a candidate iterator. It is not a controller-facing extension — an alternate Speculator need not use or expose this split.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allocator

type Allocator interface {
	// Allocate returns the build and cancel actions to take. It reconciles the
	// candidate stream against the queue's current path sets by path ID: a
	// candidate matching an in-flight path stays funded rather than starting a
	// new attempt, and one matching a path whose build already finished is
	// skipped — the generator enumerates the whole space, so suppressing
	// finished paths is the Allocator's job.
	//
	// A cancelled or expired ctx aborts with its error and no actions.
	Allocate(ctx context.Context, pathSets []entity.SpeculationPathSet, iter generator.Iterator) ([]entity.Speculation, error)
}

Allocator decides how to spend the queue's build budget over the generator's candidate stream, returning the build and cancel actions to take this run. How it rations the budget across new candidates and paths already in flight — and whether it preempts running builds — is the implementation's policy.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
Package sticky provides an allocator.Allocator that fills only free budget slots and leaves every in-flight build running — it never preempts.
Package sticky provides an allocator.Allocator that fills only free budget slots and leaves every in-flight build running — it never preempts.

Jump to

Keyboard shortcuts

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