Conversation
DI-free eager YAML loader with bind-on-demand cached sections, env substitution at bind time, section tracking for Compose/Save, and an explicit Reload. First step of the config-first bootstrap refactor.
…gisterConfigSection When a SquidStdConfig is present in the container the section binds immediately at registration time; a pre-registered config instance skips the section entirely (explicit configuration wins). The legacy deferred registry remains as fallback until the bootstrap swap completes.
The bootstrap builds (or receives) a SquidStdConfig eagerly; sections bind at registration, OnConfigLoaded hooks apply once before the logger is configured, the default file is written at StartAsync, and ConfigManagerService becomes a thin adapter whose Load() is an explicit reload that rebinds sections and re-fires the hooks. The double startup Load and its Replace-clobbering are gone. SquidStdOptions.Logger provides code-only logger configuration.
Return types of Create(SquidStdConfig, SquidStdOptions[, IContainer]) overloads changed from ISquidStdBootstrap to SquidStdBootstrap for consistency with the four sibling Create overloads. Added StartAsync remarks documenting config file persistence: "When the configuration file does not exist it is written after the configuration hooks have run, so the file reflects the effective startup configuration." Added RegisterConfigServices(string, string) remarks warning about fresh instance replacement: "Registers a fresh SquidStdConfig: do not call this on a container that already has one (the previous instance and its tracked sections would be replaced)."
RegisterEventLoop, RegisterSchedulerServices, RegisterTimerWheelService, RegisterJobSystemService, RegisterMetricsCollectionService, RegisterSecretServices and RegisterHealthChecksService accept an optional config instance that bypasses the YAML section entirely.
… and storage AddWorkers, AddWorkerManager and AddConsoleCommands accept an optional config instance; AddFileStorage is standardized on the same pattern (eager section bind, no eager default Keep). An explicit timer wheel pump config now survives the worker manager's auto-registration thanks to the section guard.
…onfig-first RegisterConfigSection's containerless fallback now registers defaults directly, the ConfigRegistrationData registry is removed, and the configuration guide, bootstrap lifecycle and scheduler docs describe the eager config-first flow with its four configuration levels.
One call registers the LuaEngineConfig instance and the Lua script engine service, replacing the manual RegisterInstance plus RegisterStdService pair. Sample and docs updated.
…ontract Load() no longer claims to create the file, ConfigureLogging() no longer claims to load, the reload section states that held references stay stale until re-resolved, the env-substitution promise is scoped to SquidStd built-in sections, and a test fixture moves inside its test class per the one-type-per-file convention.
feat(config): config-first bootstrap with eager section binding
|
|
||
| [Fact] | ||
| public void RegisterLuaEngine_NullConfig_Throws() | ||
| => Assert.Throws<ArgumentNullException>(() => new Container().RegisterLuaEngine(null!)); |
| { | ||
| var fileName = Path.HasExtension(configName) ? configName : $"{configName}.yaml"; | ||
|
|
||
| return Path.Combine(configDirectory, fileName); |
| public void RegisterConfigSection_WithSquidStdConfig_BindsImmediately() | ||
| { | ||
| using var root = new TempDirectory(); | ||
| File.WriteAllText(Path.Combine(root.Path, "app.yaml"), "eager:\n Name: fromfile\n"); |
| public void RegisterConfigSection_ExplicitInstanceAlreadyRegistered_IsSkipped() | ||
| { | ||
| using var root = new TempDirectory(); | ||
| File.WriteAllText(Path.Combine(root.Path, "app.yaml"), "eager:\n Name: fromfile\n"); |
|
|
||
| private static SquidStdConfig CreateWithYaml(TempDirectory root, string yaml) | ||
| { | ||
| File.WriteAllText(Path.Combine(root.Path, "app.yaml"), yaml); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Promotes develop to main:
Behavior notes (0.x minor)
Test plan