l0.DependencyControl.ConfigHandler¶
ConfigHandler ¶
JSON-backed configuration manager with cooperative cross-script locking. Manages one JSON file per instance. Use ConfigView (via getView or ConfigView.get) to access specific hives (nested sections) of the config.
Constructor ¶
Creates a ConfigHandler for the given file. Does not load from disk.
| param | type | description |
|---|---|---|
| filePath? | string |
|
| logger? | Logger | |
| schemaOpts? | { schemaId: string, migrate: fun(config: table, current?: string, target: string): boolean } |
The $schema this handler targets and the migration callback invoked on load when a file's $schema differs. |
Instance methods¶
getHive ¶
Returns the config table at the given hive path, creating it if missing.
| param | type | description |
|---|---|---|
| path | string[] |
Returns:
hivetable?errstring?
load ¶
Reads the config file and refreshes the in-memory config and all (or specified) views.
| param | type | description |
|---|---|---|
| views? | ConfigView|ConfigView[] | Views to refresh (default: all registered views). |
| waitLockTime? | number |
Seconds to wait for the config lock. |
Returns:
successboolean?errstring?
save ¶
Writes the config file, merging only the specified views (or the full config if nil).
| param | type | description |
|---|---|---|
| views? | ConfigView|ConfigView[] | Views to merge (default: the whole config). |
| waitLockTime? | number |
Seconds to wait for the config lock. |
Returns:
successboolean?errstring?
purgeHive ¶
Removes a view's hive from the in-memory config and returns the fresh (empty) hive.
| param | type | description |
|---|---|---|
| hive | ConfigView |
Returns:
hivetable?errstring?
Class methods¶
get ¶
Returns an existing handler for filePath, or creates and optionally loads one.
| param | type | description |
|---|---|---|
| filePath | string |
|
| logger? | Logger | |
| noLoad? | boolean |
Don't load the file immediately (default false). |
| schemaOpts? | { schemaId: string, migrate: fun(config: table, current?: string, target: string): boolean } |
Schema id this handler targets and the migration callback run when a loaded file's $schema differs. Applied on first creation; a cached handler keeps the opts it was created with. |
Returns:
handlerConfigHandler?errstring?
getView ¶
Returns a ConfigView for the given file and hive path, creating a handler if needed.
| param | type | description |
|---|---|---|
| filePath | string |
|
| hivePath | string|string[] |
|
| defaults? | table |
Default values for the hive. |
| logger? | Logger |
Returns:
viewConfigView?errstring?
getSerializableCopy ¶
Deep-copies a value while skipping private keys prefixed with "_".
| param | type | description |
|---|---|---|
| val | any |
Returns:
copyany
Fields¶
| field | type | description |
|---|---|---|
| handlers | table |