Fix bus resolver to look up context container per dispatch

The resources/context migration replaced the resolver closure with a
first-class callable from `$swoole->context()->get(...)`. That
captures the result of `$swoole->context()` once -- on the first
dispatch -- and binds the bus to the first request's per-request
container forever after.

Wrap the lookup in a fresh closure so each dispatch re-resolves
`context()` against the current Swoole coroutine. Restores the
behavior of the pre-migration `getContainer()` form.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
loks0n
2026-05-12 11:47:52 +01:00
co-authored by Claude Opus 4.7
parent 040ce6e335
commit 93e96a044d
+1 -1
View File
@@ -191,7 +191,7 @@ $http->on(Constant::EVENT_AFTER_RELOAD, function ($server) {
Console::success('Reload completed...');
});
$container->set('bus', fn ($register) => $register->get('bus')->setResolver($swoole->context()->get(...)), ['register']);
$container->set('bus', fn ($register) => $register->get('bus')->setResolver(fn (string $name) => $swoole->context()->get($name)), ['register']);
include __DIR__ . '/controllers/general.php';