refactor(insights): register CTA registry on the global $register

Persist the insight CTA registry across requests by attaching it to the
boot-time global $register, mirroring the pattern used for `geodb`,
`passwordsDictionary`, `hooks`, etc. The container resource now looks
the registry up from `$register` instead of rebuilding it on every
request.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jake Barnby
2026-05-01 14:22:10 +12:00
co-authored by Claude Opus 4.7
parent 3c4aceea48
commit d188bd7a2e
2 changed files with 9 additions and 7 deletions
+6
View File
@@ -3,6 +3,7 @@
use Appwrite\Extend\Exception;
use Appwrite\GraphQL\Promises\Adapter\Swoole;
use Appwrite\Hooks\Hooks;
use Appwrite\Insights\Cta\Action\DatabasesCreateIndex;
use Appwrite\PubSub\Adapter\Redis as PubSub;
use Appwrite\URL\URL as AppwriteURL;
use MaxMind\Db\Reader;
@@ -451,6 +452,11 @@ $register->set('promiseAdapter', function () {
$register->set('hooks', function () {
return new Hooks();
});
$register->set('insightCtaRegistry', function () {
$registry = new Registry();
$registry->set(DatabasesCreateIndex::getName(), fn () => new DatabasesCreateIndex());
return $registry;
});
$listeners = require __DIR__ . '/../listeners.php';
$register->set('bus', function () use ($listeners) {
$bus = new \Utopia\Bus\Bus();
+3 -7
View File
@@ -8,7 +8,6 @@ use Appwrite\Event\Publisher\Migration as MigrationPublisher;
use Appwrite\Event\Publisher\Screenshot as ScreenshotPublisher;
use Appwrite\Event\Publisher\StatsResources as StatsResourcesPublisher;
use Appwrite\Event\Publisher\Usage as UsagePublisher;
use Appwrite\Insights\Cta\Action\DatabasesCreateIndex;
use Appwrite\Utopia\Database\Documents\User;
use Executor\Executor;
use Utopia\Abuse\Adapters\TimeLimit\Redis as TimeLimitRedis;
@@ -27,7 +26,6 @@ use Utopia\Pools\Group;
use Utopia\Queue\Broker\Pool as BrokerPool;
use Utopia\Queue\Publisher;
use Utopia\Queue\Queue;
use Utopia\Registry\Registry as UtopiaRegistry;
use Utopia\Storage\Device;
use Utopia\Storage\Device\AWS;
use Utopia\Storage\Device\Backblaze;
@@ -130,11 +128,9 @@ $container->set('authorization', function () {
return new Authorization();
}, []);
$container->set('insightCtaRegistry', function () {
$registry = new UtopiaRegistry();
$registry->set(DatabasesCreateIndex::getName(), fn () => new DatabasesCreateIndex());
return $registry;
}, []);
$container->set('insightCtaRegistry', function ($register) {
return $register->get('insightCtaRegistry');
}, ['register']);
$container->set('dbForPlatform', function (Group $pools, Cache $cache, Authorization $authorization) {