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
- func ClassifyAtomicReplacement(active ActiveSourceVersion, candidate SourceSnapshot) (AtomicResult, Category, error)
- type ActiveSourceVersion
- type AtomicResult
- type Category
- type FileIdentity
- type FixedSource
- func (s *FixedSource) AbsolutePath() string
- func (s *FixedSource) LoadEffective(ctx context.Context, active *ActiveSourceVersion, ...) (*config.EffectiveConfig, AtomicResult, error)
- func (s *FixedSource) MaxBytes() int64
- func (s *FixedSource) ReadStable(ctx context.Context, active *ActiveSourceVersion) (SourceSnapshot, AtomicResult, error)
- type IntegrityError
- type SourceSnapshot
Constants ¶
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 )
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (s *FixedSource) LoadEffective(ctx context.Context, active *ActiveSourceVersion, opts config.LoadEffectiveOptions) (*config.EffectiveConfig, AtomicResult, error)
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 ¶
func (s *FixedSource) ReadStable(ctx context.Context, active *ActiveSourceVersion) (SourceSnapshot, AtomicResult, error)
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 ¶
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