refactor(core): replace $_SERVER cache warmup timeout with typed holder (closes #368, #367)#528
Merged
Merged
Conversation
…er (closes #368, #367) Replace the $_SERVER['WORKERMAN_CACHE_WARMUP_TIMEOUT'] superglobal mutation with a typed CacheWarmupTimeoutConfig static holder that bridges the bundle extension loader (runs during kernel boot) and Runner construction (runs later, outside the DI container via Runtime::getRunner() or ServerManager::start()/restart()). The env-var override path is preserved: WorkermanBundle::loadExtension() still reads WORKERMAN_CACHE_WARMUP_TIMEOUT from $_SERVER/$_ENV and applies it before storing the resolved value in the holder. Runner now accepts the timeout as a constructor argument with a default of 30 seconds, and the validation rule (>= 1) lives in one place on the holder.
Verifies that Runner::warmUpCache() honors the cacheWarmupTimeout constructor argument end-to-end: when the child process is stuck, the parent throws RuntimeException with the expected message after the configured timeout elapses. Uses a 1-second timeout to keep the test fast (~0.4s).
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.
Description
Closes #368, #367
Replaces the
$_SERVER['WORKERMAN_CACHE_WARMUP_TIMEOUT']superglobal mutation with a typedCacheWarmupTimeoutConfigstatic holder that bridges the bundle extension loader (runs during kernel boot) andRunnerconstruction (runs later, outside the DI container viaRuntime::getRunner()orServerManager::start()/restart()).Changes
CacheWarmupTimeoutConfigstatic holder withDEFAULTandENV_VARconstants,set()/get()/resolve()/reset()methods, and centralized validation (>= 1)Runneraccepts the timeout as a constructor argument with a default of 30 seconds;getCacheWarmupTimeout()returns the constructor valueRuntime::getRunner()reads from the holder and passes the resolved value toRunnerServerManager::start()/restart()also read from the holder (previously ignored the env-var override on thebin/console workerman:server startpath)WorkermanBundle::loadExtension()sets the holder instead of writing to$_SERVER; still reads the env-var override from$_SERVER/$_ENVand applies it before storingCacheWarmupTimeoutConfigTest, updatedRunnerTest/RuntimeTest/ServerManagerTest/WorkermanBundleIntegrationTestwith behavioral tests for the full chain (env → holder → Runner)Changelog
Added entry under [Unreleased] → Code Quality describing the refactor.
Code Review