Skip to content

refactor(core): replace $_SERVER cache warmup timeout with typed holder (closes #368, #367)#528

Merged
s2x merged 2 commits into
masterfrom
feat/issue-368-cache-warmup-timeout-config
Jul 1, 2026
Merged

refactor(core): replace $_SERVER cache warmup timeout with typed holder (closes #368, #367)#528
s2x merged 2 commits into
masterfrom
feat/issue-368-cache-warmup-timeout-config

Conversation

@s2x

@s2x s2x commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Description

Closes #368, #367

Replaces 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()).

Changes

  • New CacheWarmupTimeoutConfig static holder with DEFAULT and ENV_VAR constants, set()/get()/resolve()/reset() methods, and centralized validation (>= 1)
  • Runner accepts the timeout as a constructor argument with a default of 30 seconds; getCacheWarmupTimeout() returns the constructor value
  • Runtime::getRunner() reads from the holder and passes the resolved value to Runner
  • ServerManager::start()/restart() also read from the holder (previously ignored the env-var override on the bin/console workerman:server start path)
  • WorkermanBundle::loadExtension() sets the holder instead of writing to $_SERVER; still reads the env-var override from $_SERVER/$_ENV and applies it before storing
  • Tests: new CacheWarmupTimeoutConfigTest, updated RunnerTest/RuntimeTest/ServerManagerTest/WorkermanBundleIntegrationTest with behavioral tests for the full chain (env → holder → Runner)

Changelog

Added entry under [Unreleased] → Code Quality describing the refactor.

Code Review

  • Passed subagent code review (2 passes)
  • All review comments addressed

…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.
@s2x s2x self-assigned this Jun 30, 2026
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).
@s2x s2x merged commit 30e9922 into master Jul 1, 2026
11 checks passed
@s2x s2x deleted the feat/issue-368-cache-warmup-timeout-config branch July 1, 2026 05:19
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.

[Code Quality] WorkermanBundle mutates SERVER as a side effect of extension loading

1 participant