Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SC-580: Implement "boot" config load #256

Closed
wants to merge 19 commits into from
Closed

Conversation

hexaglow
Copy link
Contributor

@hexaglow hexaglow commented Aug 13, 2024

Implement the config loading flow at boot.

This should support loading config from a JSON file (as like the current behaviour) and integrate its changes into the authoritative configuratio.
The challenge is that the authoritative config can be changed at any time by the user (e.g. via the UI) and these changes will not be reflected in the manually written / generated external config files.

Therefore we need to detect what has changed between the current external config and the previous external config, and apply only these changes to the live config, taking care not to squash other unrelated changes. To do this properly we need to be aware of the structure of the config, in particular which values represent a single logical group.

@hexaglow
Copy link
Contributor Author

I have factored out and expanded on the logic into the new split package. I decided to only support 'JSON-style' types (map[string]any, []any, primitives) to avoid lots of reflection. This may require a Marshal-Unmarshal round trip to convert, which is inefficient, but this code will only be used once on app start anyway so it doesn't matter.

The most complicated part is the Diff algorithm which detects changes taking into account the splits.

This code doesn't touch the filesystem because I was investigating an alternative design which doesn't require splitting every page into its own file and keeps the live config format matching the external config format. I would appreciate a review of the general approach.

Currently I'm integrating it into appconf to actually load the boot config.

@hexaglow hexaglow changed the base branch from main to feat/split August 29, 2024 14:54
@hexaglow hexaglow deleted the branch feat/split August 29, 2024 15:28
@hexaglow hexaglow closed this Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants