config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: LGPL-2.1 Imports: 12 Imported by: 0

README

mod/config

mod/config loads and validates runtime configuration before any long-lived subsystem starts. Schema-level parsing is generated into target/stconf; this package adds file handling, preset loading, and business validation that depends on multiple config sections.

Place in the runtime

flowchart TB
  file["YAML, JSON, or HJSON"] --> config["mod/config"]
  presets["generated presets"] --> config
  config --> schema["target/stconf"]
  schema --> validation["business validation"]
  validation --> runtime["runtime assembly"]

Responsibilities

  • Detect config format from the file extension.
  • Decode YAML, JSON, and HJSON into generated config structs.
  • Apply defaults and schema validation through target/stconf.
  • Validate cross-section business rules such as listener modes, TLS pairs, static routing, profiling bind address, storage limits, and rate-limit budgets.
  • Load generated presets for CLI commands.

Contracts

  • A config is either valid before runtime assembly or the process exits with an English error.
  • Validation must catch unsafe public pprof binds and inconsistent web listener settings.
  • Generated files in target/stconf are source-of-truth for schema defaults and field documentation.
  • Business validation should stay deterministic and should not perform network calls.

Important files

  • init.go: generated parser entry and business-validation handoff.
  • helper.go: shared patterns, reserved keys, and validation constants.
  • validate.go: cross-section validation.
  • config_test.go: format, default, and cross-section validation coverage.
  • profiling_test.go: profiling-listener safety coverage.

Operational notes

When adding a new config field, update the schema in yml/config, regenerate target/stconf, and add business validation here only if the rule cannot be expressed in the schema.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(pathToFile string) (*stcfg.ConfigObj, error)

New parses a config file through stconf, applying defaults and schema min/max before business validation.

Types

This section is empty.

Jump to

Keyboard shortcuts

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