luartconfig

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromEnv

func FromEnv(prefix string) (luart.Config, error)

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

func Load(path string) (luart.Config, error)

Load reads a config file, choosing JSON or YAML by extension (.json → JSON; .yaml/.yml → YAML).

func LoadJSON

func LoadJSON(path string) (luart.Config, error)

LoadJSON reads a JSON config file into a luart.Config.

func LoadJSONString

func LoadJSONString(jsonStr string) (luart.Config, error)

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 LoadYAML

func LoadYAML(path string) (luart.Config, error)

LoadYAML reads a YAML config file into a luart.Config.

func Resolve

func Resolve(path, envPrefix string) (luart.Config, error)

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

func ResolveJSONString(jsonStr, envPrefix string) (luart.Config, error)

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).

func (Spec) Config

func (s Spec) Config() (luart.Config, error)

Config converts the Spec into a validated luart.Config (parsing durations). Unset fields stay at the zero value, so luart.New applies its own defaults.

Jump to

Keyboard shortcuts

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