Documentation
¶
Overview ¶
Package luartconfig loads a luart.Config from JSON, YAML, or environment variables. It lives in a subpackage so the core luart package stays dependency-free (the YAML dependency is only pulled in when this package is imported).
Only the serializable numeric/duration fields are loaded; Libs, Metrics, and Logger are code-injected on the returned Config by the caller.
Sources can be combined with the precedence env > file > defaults via Resolve (or env > JSON string > defaults via ResolveJSONString). The merge is field-by-field: an env var overrides only the one field it sets, leaving the rest to the file (then to luart.New's built-in defaults).
Since: 2026-06-07
Index ¶
- func FromEnv(prefix string) (luart.Config, error)
- func Load(path string) (luart.Config, error)
- func LoadJSON(path string) (luart.Config, error)
- func LoadJSONString(jsonStr string) (luart.Config, error)
- func LoadYAML(path string) (luart.Config, error)
- func Resolve(path, envPrefix string) (luart.Config, error)
- func ResolveJSONString(jsonStr, envPrefix string) (luart.Config, error)
- type Spec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromEnv ¶
FromEnv builds a luart.Config from environment variables, each named prefix+FIELD: MAX_STATES, MEMORY_BUDGET_BYTES, IDLE_TTL, JANITOR_INTERVAL, EXEC_TIMEOUT. Unset variables leave the zero value (defaults apply at luart.New).
func Load ¶
Load reads a config file, choosing JSON or YAML by extension (.json → JSON; .yaml/.yml → YAML).
func LoadJSONString ¶
LoadJSONString parses an in-memory JSON string (not a file) into a luart.Config. JSON only — useful when the config comes from a remote store, a command-line flag, or a test rather than from disk.
Since: 2026-06-07
func Resolve ¶
Resolve builds a luart.Config from a config file overlaid by environment variables, applying the precedence env > file > defaults: the file at path is the base, then each env var (prefix+FIELD) that is set overrides that one field. An empty path skips the file (env > defaults). Fields set by neither source stay at the zero value, so luart.New applies its built-in defaults.
Since: 2026-06-07
func ResolveJSONString ¶
ResolveJSONString is Resolve with an in-memory JSON string as the base instead of a file: the precedence is reconstructed to env > jsonStr > defaults. An empty jsonStr makes it env > defaults.
Since: 2026-06-07
Types ¶
type Spec ¶
type Spec struct {
MaxStates *int `json:"maxStates,omitempty" yaml:"maxStates,omitempty"`
MemoryBudgetBytes *uint64 `json:"memoryBudgetBytes,omitempty" yaml:"memoryBudgetBytes,omitempty"`
IdleTTL string `json:"idleTTL,omitempty" yaml:"idleTTL,omitempty"`
JanitorInterval string `json:"janitorInterval,omitempty" yaml:"janitorInterval,omitempty"`
ExecTimeout string `json:"execTimeout,omitempty" yaml:"execTimeout,omitempty"`
}
Spec is the serializable form of luart.Config. Durations are strings (e.g. "500ms", "30s") so JSON, YAML, and env all parse them the same way. The numeric fields are pointers so an unset field is distinguishable from a zero value, which is what lets sources merge field-by-field (see merge / Resolve).