genpin

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package genpin defines the narrow request-context contract for retaining runtime configuration generation ownership beyond an HTTP handler lease.

RuntimeGenerationID here is the request-plane generation identity (runtimehost.GenerationMeta.ID). It is distinct from executable-policy / snapshot generation IDs and from model registry/catalog generations.

Implementations live in composition (runtimehost); core runtime and terminal-work code consume only this package so they never import internal/infra/runtimehost.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithRetainer

func WithRetainer(ctx context.Context, r Retainer) context.Context

WithRetainer attaches a generation pin retainer to ctx. A nil parent ctx is tolerated and substituted with context.Background so the result is always non-nil.

Types

type Kind

type Kind uint8

Kind classifies a retained runtime-generation pin.

const (
	// KindSSE retains ownership for a streaming/SSE response handed beyond the
	// request lease.
	KindSSE Kind = 1
	// KindAsync retains ownership for request-spawned asynchronous work.
	KindAsync Kind = 2
	// KindProvider retains ownership for durable terminal/provider settlement.
	KindProvider Kind = 3
)

type Pin

type Pin interface {
	Kind() Kind
	Release()
}

Pin retains one runtime configuration generation reference exactly once. Release is idempotent and must not underflow generation ownership.

type Retainer

type Retainer interface {
	// RuntimeInstanceID returns the opaque process/manager incarnation identity
	// bound to this retainer. Empty when no generation is bound.
	RuntimeInstanceID() string
	// RuntimeGenerationID returns the bound request-plane generation identity.
	// Empty when no generation is bound.
	RuntimeGenerationID() string
	// Retain acquires a child pin of the given kind. Invalid kinds and
	// post-lease spawn attempts fail closed without consuming ownership.
	Retain(kind Kind) (Pin, bool)
}

Retainer acquires independent child pins while a request lease (or equivalent spawn right) is still held. Each successful Retain increments generation ownership; pins are independently releasable.

func FromContext

func FromContext(ctx context.Context) (Retainer, bool)

FromContext returns the request-bound retainer when present. A nil ctx is tolerated and returns (nil, false).

Jump to

Keyboard shortcuts

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