config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config parses the WAVEFRONT_* environment once at startup into an immutable Config. Required vars missing ⇒ MissingError; malformed values ⇒ InvalidError (both name the offending var). Load uses the functional-options pattern: production calls config.Load(); tests inject a fixed environment with config.Load(config.WithLookup(fake)).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	BundlePath            string
	UpstreamBaseURL       string
	ListenAddr            string
	MetricsAddr           string
	ContractVersionHeader string
	RequestTimeout        time.Duration
	MaxBodyBytes          int64
	LogLevel              slog.Level
}

func Load

func Load(opts ...Option) (*Config, error)

Load parses the WAVEFRONT_* environment once into an immutable Config. Production: config.Load(). Tests: config.Load(config.WithLookup(fake)).

type InvalidError

type InvalidError struct {
	Var   string
	Value string
	Err   error
}

func (*InvalidError) Error

func (e *InvalidError) Error() string

func (*InvalidError) Unwrap

func (e *InvalidError) Unwrap() error

type Lookuper

type Lookuper func(key string) (string, bool)

Lookuper resolves an environment variable: its value and whether it is set. It matches the signature of os.LookupEnv.

type MissingError

type MissingError struct{ Var string }

func (*MissingError) Error

func (e *MissingError) Error() string

type Option

type Option func(*loader)

Option configures Load.

func WithLookup

func WithLookup(fn Lookuper) Option

WithLookup overrides the environment source (default os.LookupEnv). Tests use it to supply a fixed, in-memory environment.

Jump to

Keyboard shortcuts

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