pooling

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package pooling is the pure worker-pooling placement policy (ADR-0046): it maps a function to either a solo worker (its own process, the default) or a shared pool worker keyed by (namespace, runtime, worker-id). It is the placement counterpart to scheduler.Placement (node selection, ADR-0017) — pooling answers WHICH shared worker within a node a function joins, never which node.

The policy is pure and deterministic: no I/O, no clock, no store. The reconciler (internal/function) lists the same-key functions from the store and serializes the admitted members into the pool worker's manifest; this package only decides placement.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assigner

type Assigner interface {
	// Assign places fn. Solo when fn.Spec.Pooling.Worker == "". Otherwise the key is
	// (fn.Namespace, fn.Spec.Runtime, fn.Spec.Pooling.Worker): members are ordered by name,
	// the first `limit` are admitted (Pooled), the rest Rejected with a clear reason.
	// Deterministic — a pure function of declared membership, stable under reconcile order.
	Assign(fn *v1.Function, sameKey []*v1.Function, limit int) (Assignment, error)
}

Assigner places a function given every function declaring its (namespace, runtime, worker-id) — fn included, Ready or not — and the per-pool limit. The V1 driver is the explicit worker-id policy (NewAssigner); the automatic/threshold policy is the future second driver behind this port (ADR-0046 Open questions).

func NewAssigner

func NewAssigner() Assigner

NewAssigner returns the V1 explicit-worker-id pooling policy.

type Assignment

type Assignment struct {
	Pooled   bool
	Key      PoolKey
	Rejected bool
	Reason   string
}

Assignment is where a function lands. Pooled==false ⇒ a solo worker (Key is the zero value). Rejected==true ⇒ pooled but over the cap: hold the function NotReady with Reason.

type PoolKey

type PoolKey struct {
	Namespace v1.NamespaceName
	Runtime   string
	Worker    string // the owner-chosen worker id (FunctionSpec.Pooling.Worker)
}

PoolKey identifies one shared worker: functions sharing all three co-locate in one worker_threads pool worker. Pooling never consults the resourceGroup (ADR-0046 Decision 2) — a different worker id, runtime, or namespace is a different worker.

func KeyOf

func KeyOf(fn *v1.Function) (PoolKey, bool)

KeyOf returns the pool key a function declares, and whether it opts into pooling at all (a non-empty worker id). It is the canonical (ns, runtime, worker) grouping used by both the policy and the reconciler so the two never disagree on what "same key" means.

Jump to

Keyboard shortcuts

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