Repository navigation
feat(realtime): let a deployment run per-worker cleanup on worker exit - #14705
Conversation
Swoole keeps one workerExit callback, and realtime's own close-out holds it, so an embedding app has nowhere to drain per-worker state.
|
Review complete. No issues found — approved ✅. This minimal change wires a worker-exit hook into the realtime entrypoint so per-worker cleanup runs exactly once when a Swoole realtime worker exits. The hook is defined behind a
The hook ordering versus Swoole's own worker-stop semantics, the Reviewed commit: 2c494f3 |
🟢 Tier S · Ready to mergeAdds an overridable Latest changes: The newest commit updates the hook documentation to clarify that connection
📂 Walkthrough · 1
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
What does this PR do?
Adds an overridable
realtimeWorkerExit(int $workerId)toapp/realtime.php, called once from the worker-exit callback after the worker's connections are closed. It does nothing in CE.An app that embeds the realtime server (Cloud) can already override per-worker setup through
getTelemetry(),triggerStats()and the otherfunction_existshooks, but has no way to run anything when a worker exits. The adapter'sonWorkerExit()calls Swoole's$server->on('workerExit', …), which keeps one callback, and realtime's own connection close-out holds it.Cloud needs it to drain a per-worker buffered usage publisher before the worker goes: it batches realtime's stats-usage events into one queue message per batch instead of one per event. An exception from the hook is logged, so it cannot stop the close-out that runs before it.
Test Plan
php -l app/realtime.php.$exitSweptguard.Related PRs and Issues
Checklist