configsource

package
v0.1.0-rc.1 Latest Latest
Warning

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

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

Documentation

Overview

Package configsource provides the bounded fixed-path configuration source for runtime reload (versioned-runtime-reloadable-proxy-configuration).

FixedSource resolves an absolute startup path and implements ReadStable with handle re-stat, path revalidation, and atomic-replacement enforcement. This package must not grow a file watcher, mtime poller, or automatic reload loop.

Index

Constants

View Source
const (
	CategoryOK                = config.CategoryOK
	CategoryMissing           = config.CategoryMissing
	CategoryEmpty             = config.CategoryEmpty
	CategoryWhitespace        = config.CategoryWhitespace
	CategoryOversize          = config.CategoryOversize
	CategoryUnstable          = config.CategoryUnstable
	CategoryNonAtomicUpdate   = config.CategoryNonAtomicUpdate
	CategoryUnsupportedType   = config.CategoryUnsupportedType
	CategoryMalformedYAML     = config.CategoryMalformedYAML
	CategoryMultipleDocuments = config.CategoryMultipleDocuments
	CategoryTrailingContent   = config.CategoryTrailingContent
	CategoryUnknownCoreField  = config.CategoryUnknownCoreField
	CategoryPartialUnreadable = config.CategoryPartialUnreadable
)
View Source
const DefaultMaxBytes int64 = config.DefaultConfigMaxBytes

DefaultMaxBytes is the startup-fixed upper bound for one accepted source snapshot.

Variables

This section is empty.

Functions

func ClassifyAtomicReplacement

func ClassifyAtomicReplacement(active ActiveSourceVersion, candidate SourceSnapshot) (AtomicResult, Category, error)

Types

type ActiveSourceVersion

type ActiveSourceVersion struct {
	HandleIdentity FileIdentity
	PrivateDigest  [32]byte
}

ActiveSourceVersion is the last accepted source identity used for no-op / non-atomic comparisons (published generation or effective no-op baseline).

type AtomicResult

type AtomicResult string

ClassifyAtomicReplacement enforces requirement 2.9: changed content with the same handle identity is a non-atomic in-place update; identical digest may no-op; a new identity is eligible for reload.

const (
	AtomicEligible AtomicResult = "eligible"
	AtomicNoop     AtomicResult = "noop"
	AtomicReject   AtomicResult = "reject_non_atomic"
)

func LoadEffectiveFromPath

func LoadEffectiveFromPath(ctx context.Context, path string, active *ActiveSourceVersion, opts config.LoadEffectiveOptions) (*config.EffectiveConfig, AtomicResult, error)

LoadEffectiveFromPath resolves one fixed source and delegates to LoadEffective.

type Category

type Category = config.LoadCategory

Category aliases the core secret-safe load category so driving adapters and typed decoding report one stable vocabulary without reversing dependencies.

func CategoryOf

func CategoryOf(err error) (Category, bool)

CategoryOf returns the integrity/decode category when err wraps or is an IntegrityError or a config.LoadError from the shared effective-load pipeline.

func ClassifyBytes

func ClassifyBytes(raw []byte, maxBytes int64) (Category, error)

ClassifyBytes classifies a raw snapshot against the bounded source contract before typed YAML decode. It does not decode YAML; empty/whitespace/oversize are rejected here so decode never sees them.

maxBytes <= 0 selects DefaultMaxBytes. Classification is secret-safe: errors never include the raw payload.

func ClassifyPathPresence

func ClassifyPathPresence(exists, isRegular bool) (Category, error)

ClassifyPathPresence maps filesystem presence to a source category without reading contents. Used by table fixtures and the future ReadStable path.

func ClassifyStability

func ClassifyStability(beforeSize, afterSize int64, beforeID, afterID FileIdentity) (Category, error)

ClassifyStability rejects torn/partial reads where handle metadata changed across the bounded read window (requirement 2.1–2.2).

type FileIdentity

type FileIdentity struct {
	Platform string
	Scheme   string
	Opaque   [32]byte
}

FileIdentity is a platform-stable handle identity used to prove atomic replacement. Scheme records the provenance of Opaque so identities derived from different metadata can never be mistaken for the same physical file.

type FixedSource

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

FixedSource is the startup-fixed absolute configuration path used by every reload. It does not watch the filesystem; callers must invoke ReadStable explicitly after an operator trigger.

func NewFixedSource

func NewFixedSource(path string, maxBytes int64) (*FixedSource, error)

NewFixedSource resolves path to an absolute location and stores the startup-fixed size limit. maxBytes <= 0 selects DefaultMaxBytes.

func (*FixedSource) AbsolutePath

func (s *FixedSource) AbsolutePath() string

AbsolutePath returns the startup-resolved absolute source path.

func (*FixedSource) LoadEffective

LoadEffective reads one stable snapshot from s and runs the shared pure effective-configuration pipeline. Filesystem ownership remains in this driving adapter; core/config only sees bounded bytes and explicit options.

func (*FixedSource) MaxBytes

func (s *FixedSource) MaxBytes() int64

MaxBytes returns the startup-fixed read limit.

func (*FixedSource) ReadStable

ReadStable opens the fixed path, captures handle identity, reads one bounded snapshot, revalidates the same handle and path identity, classifies the bytes, and enforces atomic-replacement rules against active when non-nil.

On success AtomicResult is AtomicEligible (first read / new identity), AtomicNoop (same identity+digest), or the call fails with CategoryNonAtomicUpdate when the same identity changed digest.

type IntegrityError

type IntegrityError struct {
	Category Category
	Limit    int64 // set for oversize; otherwise 0
}

IntegrityError is a secret-safe source-integrity or pre-decode failure. Error strings carry only the category (and bounded limits), never raw bytes.

func (*IntegrityError) Error

func (e *IntegrityError) Error() string

type SourceSnapshot

type SourceSnapshot struct {
	SourceID       string
	HandleIdentity FileIdentity
	Size           int64
	ModTime        time.Time
	PrivateDigest  [32]byte
	Bytes          []byte
	ReadAt         time.Time
}

SourceSnapshot is one accepted bounded read of the fixed startup path.

Jump to

Keyboard shortcuts

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