snapshotgen

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: 10 Imported by: 0

Documentation

Overview

Package snapshotgen publishes immutable runtime policy/rating generations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecutableGeneration

type ExecutableGeneration struct {
	ID          int64
	Version     string
	SourceID    string
	PublishedAt time.Time
	State       economics.SnapshotState
	Reason      string

	Usage       economics.Snapshot[economics.PolicyRulesView]
	Concurrency economics.Snapshot[economics.PolicyRulesView]
	Rating      economics.Snapshot[economics.RatingCatalogView]

	RequestRegistrations    []authority.RequestRegistration
	AttemptRegistrations    []authority.AttemptRegistration
	ConcurrencyRegistration *authority.ConcurrencyRegistration

	// RequestCoord/AttemptCoord are the concrete immutable evaluators for this
	// generation. New admissions must use these when present (D10).
	RequestCoord *authoritycoord.RequestCoordinator
	AttemptCoord *authoritycoord.AttemptCoordinator

	MaxActiveRequests int
	// contains filtered or unexported fields
}

ExecutableGeneration is one immutable published set of evaluator objects used by admission and settlement (requirements 9.1–9.9; design D10).

func CompileExecutable

func CompileExecutable(contrib runtimegen.GenerationContribution) (*ExecutableGeneration, error)

CompileExecutable builds an ExecutableGeneration from a validated contribution.

func (*ExecutableGeneration) AddPendingProvider

func (g *ExecutableGeneration) AddPendingProvider(providerID string)

AddPendingProvider tracks pending terminal-work references to a provider ID. Prefer AddPendingWork for WorkID-keyed idempotent ownership (task 3.6).

func (*ExecutableGeneration) AddPendingWork

func (g *ExecutableGeneration) AddPendingWork(workID, providerID string) bool

AddPendingWork registers idempotent pending ownership for one WorkID. Returns false when workID was already present (no refcount bump).

func (*ExecutableGeneration) CanRemoveProvider

func (g *ExecutableGeneration) CanRemoveProvider(providerID string) bool

CanRemoveProvider reports whether providerID may be removed from configuration.

func (*ExecutableGeneration) ClearPendingProvider

func (g *ExecutableGeneration) ClearPendingProvider(providerID string)

ClearPendingProvider decrements a pending provider reference.

func (*ExecutableGeneration) ClearPendingWork

func (g *ExecutableGeneration) ClearPendingWork(workID string)

ClearPendingWork clears WorkID-keyed pending ownership exactly once.

func (*ExecutableGeneration) EnforcementMaxActive

func (g *ExecutableGeneration) EnforcementMaxActive() int

EnforcementMaxActive returns the concurrency limit from the actual generation objects.

func (*ExecutableGeneration) EvidenceObjectID

func (g *ExecutableGeneration) EvidenceObjectID() string

EvidenceObjectID identifies the executable object for version evidence (9.9).

func (*ExecutableGeneration) LiveRefs

func (g *ExecutableGeneration) LiveRefs() int64

LiveRefs reports outstanding live request bindings.

func (*ExecutableGeneration) PendingProviderIDs

func (g *ExecutableGeneration) PendingProviderIDs() []string

PendingProviderIDs returns provider IDs with outstanding pending work.

func (*ExecutableGeneration) PendingWorkCount

func (g *ExecutableGeneration) PendingWorkCount() int

PendingWorkCount reports outstanding WorkID-keyed pending entries.

func (*ExecutableGeneration) Release

func (g *ExecutableGeneration) Release()

Release decrements the live reference count.

func (*ExecutableGeneration) Retain

func (g *ExecutableGeneration) Retain()

Retain increments the live reference count (requirement 9.8).

func (*ExecutableGeneration) ValidateComplete

func (g *ExecutableGeneration) ValidateComplete() error

ValidateComplete rejects metadata-only generations that lack executable objects.

type Publisher

type Publisher struct {
	// contains filtered or unexported fields
}

Publisher atomically publishes immutable generations for request binding.

func NewPublisher

func NewPublisher() *Publisher

NewPublisher returns an empty publisher (Current is nil until Publish).

func (*Publisher) AddPendingWork

func (p *Publisher) AddPendingWork(generationID int64, workID, providerID string) bool

AddPendingWork registers WorkID-keyed pending ownership on the named generation.

func (*Publisher) CanRemoveProvider

func (p *Publisher) CanRemoveProvider(providerID string) bool

CanRemoveProvider reports whether providerID may be removed across retained generations.

func (*Publisher) ClearPendingProvider

func (p *Publisher) ClearPendingProvider(generationID int64, providerID string)

ClearPendingProvider clears a pending provider ref on the named generation.

func (*Publisher) ClearPendingWork

func (p *Publisher) ClearPendingWork(generationID int64, workID string)

ClearPendingWork clears WorkID-keyed pending ownership on the named generation.

func (*Publisher) Current

func (p *Publisher) Current() *RuntimeGeneration

Current returns the active generation pointer, or nil when none published.

func (*Publisher) CurrentExecutable

func (p *Publisher) CurrentExecutable() *ExecutableGeneration

CurrentExecutable returns the active executable generation, if any.

func (*Publisher) LookupExecutable

func (p *Publisher) LookupExecutable(id int64) *ExecutableGeneration

LookupExecutable returns a retained generation by ID (in-flight / pending drain).

func (*Publisher) MarkUnusable

func (p *Publisher) MarkUnusable(state economics.SnapshotState, reason string) *RuntimeGeneration

MarkUnusable updates readiness of the active generation without replacing snapshot Values with an unrelated version (requirements 11.3, 11.7). Unknown states are rejected and the prior generation is preserved.

func (*Publisher) Publish deprecated

Publish stores gen as the active metadata compatibility view with a new monotonic ID. Callers must treat returned generations as immutable.

Deprecated: metadata-only publication is not an enforcement path (D10). Use PublishExecutable for admission/settlement evaluator objects, or PublishMetadata for additive source-fetch compatibility views (requirement 11.2).

func (*Publisher) PublishExecutable

func (p *Publisher) PublishExecutable(gen *ExecutableGeneration) (*ExecutableGeneration, error)

PublishExecutable validates and publishes an executable generation. On validation failure the prior executable generation remains active (9.6).

func (*Publisher) PublishMetadata

func (p *Publisher) PublishMetadata(gen RuntimeGeneration) *RuntimeGeneration

PublishMetadata stores gen as the active metadata compatibility view with a new monotonic ID (requirement 11.2). Callers must treat returned generations as immutable. Enforcement uses PublishExecutable (D10).

func (*Publisher) UnresolvedProviderIDs

func (p *Publisher) UnresolvedProviderIDs() []string

UnresolvedProviderIDs aggregates pending provider IDs across retained generations.

type RuntimeGeneration

RuntimeGeneration is one immutable published set of usage, concurrency, and rating snapshots (design: Publication). Metadata views remain for compatibility; enforcement uses ExecutableGeneration (D10).

Jump to

Keyboard shortcuts

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