feat(ConfigLoader): add validation for complete configuration before warmUp#139
Merged
feat(ConfigLoader): add validation for complete configuration before warmUp#139
Conversation
added 2 commits
April 14, 2026 21:42
…warmUp Add validation in warmUp() method to ensure all three config sections (workerman, process, scheduler) are set before writing to cache. This prevents incomplete configuration from being cached and causing hard-to-debug errors later during use. Closes #35
4b0cf11 to
b4ca6c4
Compare
…warmUp
Add ConfigSection enum and validation in warmUp() to ensure all three
config sections (workerman, process, scheduler) are set before writing
to cache.
- Add ConfigSection enum with WORKERMAN, PROCESS, SCHEDULER cases
- Use string keys ('workerman', 'process', 'scheduler') for clarity
- Add validation in warmUp() with descriptive error message
- Add comprehensive test coverage
BREAKING CHANGE: Cache format changed from numeric indices [0,1,2]
to string keys ['workerman', 'process', 'scheduler']
Closes #35
b4ca6c4 to
10fb790
Compare
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
Add validation in
warmUp()method to ensure all three config sections (workerman, process, scheduler) are set before writing to cache.Problem
In the
ConfigLoaderclass, the$configproperty is populated by three separate setter calls. If thewarmUp()method is called before all three sections are set, the saved configuration will be incomplete. There is no validation that all three sections have been set.Changes
src/ConfigSection.php (new file)
ConfigSectionwith cases: WORKERMAN, PROCESS, SCHEDULERsrc/ConfigLoader.php
warmUp()method usingConfigSectionenumLogicExceptionwith descriptive message when any config section is missingConfigSectionenum instead of magic numberstests/ConfigLoaderTest.php (new file)
Testing
Unit tests pass:
BREAKING CHANGE
Cache format changed from numeric indices to string keys:
[0 => ..., 1 => ..., 2 => ...]['workerman' => ..., 'process' => ..., 'scheduler' => ...]Existing cache must be cleared after upgrade:
rm -rf var/cache/*Closes #35