Reading a Small Configuration File
Configuration should have a declared structure, visible defaults, and a clear reaction to invalid supplied values.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace default and supplied data
A settings file omitting timeout may receive a default of 30 seconds. A supplied negative timeout normally requires a diagnostic under a nonnegative rule. Required and optional fields define when omission is expected.
Record the active settings sources
A command option can override a file value when that precedence is documented. Test a conflict between two sources to verify which one wins. See merging settings.[1]
Apply effective values after parsing a typed structure
A file can set timeout_ms=500 under the chosen syntax while omitting a retry count. The loader can apply a default retry policy after validating known values. The string "500" needs deliberate conversion if the schema requires a number. See overriding settings with maps.
Parse file → timeout_ms supplied
Validate positive time unit and supported range
Fill absent retry count by the documented rule
Return typed settings with effective values
Decide which errors block operation
A typo in a key can silently leave defaults in effect if unknown names are ignored. Strict validation can report it instead. Test a minimal valid file and a malformed change to an existing key.