Commit 7c4247d
committed
feat: shared-state APIs (set_vars/get_vars) + readiness wait
Adds the worker-to-HTTP shared-state surface deferred from the
config+ensure split (php#2393):
- frankenphp_set_vars(array $vars): void publishes a snapshot from a
background worker. Persistent (pemalloc) memory, RWMutex-protected,
cross-thread safe. Skips work when data is identical (=== check).
- frankenphp_get_vars(string $name): array reads the latest snapshot.
Pure read; throws if the worker is not running or has not published
yet.
- ensure_background_worker now blocks until the named worker has called
set_vars at least once (the readiness signal). The fire-and-forget
semantics from the config-only PR become a stronger contract here
with no API change visible to callers.
- Two-mode ensure: fail-fast in HTTP-worker bootstrap (before
frankenphp_handle_request) so a broken dependency surfaces at boot
rather than serving degraded traffic; tolerant inside requests so
the restart-with-backoff cycle can recover from transient boot
failures.
- Boot-failure capture: the worker's last PHP error (message, file,
line, exit status) is recorded so ensure() can throw a descriptive
RuntimeException on timeout.
The persistent storage path uses opcache-immutable arrays (zero-copy
share), interned strings (no copy), and rich type support: null,
scalars, arrays (nested), enums.
Tests cover happy-path roundtrips, type coverage, ensure() blocking
on first set_vars, fail-fast vs tolerant modes, boot-failure
reporting, and the catch-all + scope interactions with vars.1 parent 0368ebf commit 7c4247d
41 files changed
Lines changed: 1362 additions & 735 deletions
File tree
- .github/workflows
- caddy
- testdata
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
| 178 | + | |
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| |||
0 commit comments