Commit 67a1a32
committed
refactor: simplify bg-worker internals + apply review feedback
Combines three semantic units now that the per-scope routing,
catch-all dispatch, and ensure() API have settled.
1. Internals refactor (was two refactor commits):
- Drops backgroundWorkerRegistry; the per-scope lookup resolves
directly to the *worker that owns each name. The catch-all
*worker hosts its lazy-spawned threads in catchAllNames keyed by
runtimeName.
- threadbackgroundworker.go gains runtimeName + backgroundReady so
one catch-all *worker can host multiple per-name threads, each
carrying its own metric label, FRANKENPHP_WORKER_NAME and
readiness slot.
- Worker identity (the runtime name) routes through the CGI
pipeline so $_SERVER['FRANKENPHP_WORKER'] reflects the
user-facing name on every request, not just bg-worker boot.
2. Review feedback (dunglas + AlliBalliBaba):
- BackgroundScope -> Scope (and NextScope / WithRequestScope /
WithWorkerScope), keeping the type opaque + reusable.
- backgroundScope -> scope on worker, workerOpt, frankenPHPContext,
FrankenPHPModule.
- $_SERVER['FRANKENPHP_WORKER'] now carries the user-facing worker
name instead of "1"; drops the parallel FRANKENPHP_WORKER_NAME
injection.
- Cap-error wording trimmed to read cleanly under JSON config too.
- ScopeLabel + SetScopeLabel registry; Caddy module resolves a
human-friendly label per php_server (route host matcher ->
user-set Caddy server name -> first listener address).
- reserveBackgroundWorkerThreads extracted from calculateMaxThreads
so the lazy-start cases (named/named-with-cap/catch-all) read in
one place.
- Stub doc nits (third-person godoc); tests adopt
requireSentinelEventually / require.NoFileExists /
require.ErrorContains / assert.WithinDuration.
- background_worker_*_test.go renamed to bgworker*_test.go to
match the bgworker.go source (no underscores in file-name
prefixes).
3. Comment cleanup: trims paragraph-length docs in the bg-worker
subsystem to match the surrounding terseness; ~120 fewer comment
lines, no semantic changes.1 parent 5120d3e commit 67a1a32
25 files changed
Lines changed: 781 additions & 902 deletions
File tree
- caddy
- testdata
This file was deleted.
0 commit comments