@zintrust/core 0.1.40 → 0.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/zintrust-main.d.ts.map +1 -1
- package/bin/zintrust-main.js +22 -1
- package/package.json +24 -4
- package/public/error-pages/404.html +2 -2
- package/src/auth/Auth.js +1 -1
- package/src/boot/Application.d.ts +1 -16
- package/src/boot/Application.d.ts.map +1 -1
- package/src/boot/Application.js +2 -290
- package/src/boot/Server.d.ts +1 -1
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/bootstrap.js +50 -16
- package/src/boot/registry/registerRoute.d.ts +6 -0
- package/src/boot/registry/registerRoute.d.ts.map +1 -0
- package/src/boot/registry/registerRoute.js +96 -0
- package/src/boot/registry/runtime.d.ts +15 -0
- package/src/boot/registry/runtime.d.ts.map +1 -0
- package/src/boot/registry/runtime.js +364 -0
- package/src/boot/registry/type.d.ts +25 -0
- package/src/boot/registry/type.d.ts.map +1 -0
- package/src/boot/registry/type.js +1 -0
- package/src/boot/registry/worker.d.ts +6 -0
- package/src/boot/registry/worker.d.ts.map +1 -0
- package/src/boot/registry/worker.js +35 -0
- package/src/cache/drivers/KVRemoteDriver.d.ts.map +1 -1
- package/src/cache/drivers/KVRemoteDriver.js +14 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +94 -34
- package/src/cli/ErrorHandler.js +1 -1
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -1
- package/src/cli/commands/ConfigCommand.js +3 -5
- package/src/cli/commands/ContainerProxiesCommand.d.ts +5 -0
- package/src/cli/commands/ContainerProxiesCommand.d.ts.map +1 -0
- package/src/cli/commands/ContainerProxiesCommand.js +77 -0
- package/src/cli/commands/ContainerWorkersCommand.d.ts +5 -0
- package/src/cli/commands/ContainerWorkersCommand.d.ts.map +1 -0
- package/src/cli/commands/ContainerWorkersCommand.js +57 -0
- package/src/cli/commands/D1LearnCommand.d.ts +9 -0
- package/src/cli/commands/D1LearnCommand.d.ts.map +1 -0
- package/src/cli/commands/D1LearnCommand.js +143 -0
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/D1MigrateCommand.js +55 -16
- package/src/cli/commands/DeployCommand.d.ts +16 -0
- package/src/cli/commands/DeployCommand.d.ts.map +1 -0
- package/src/cli/commands/DeployCommand.js +110 -0
- package/src/cli/commands/DeployContainerProxiesCommand.d.ts +5 -0
- package/src/cli/commands/DeployContainerProxiesCommand.d.ts.map +1 -0
- package/src/cli/commands/DeployContainerProxiesCommand.js +27 -0
- package/src/cli/commands/DeployContainerWorkersCommand.d.ts +5 -0
- package/src/cli/commands/DeployContainerWorkersCommand.d.ts.map +1 -0
- package/src/cli/commands/DeployContainerWorkersCommand.js +27 -0
- package/src/cli/commands/DockerComposeCommandUtils.d.ts +3 -0
- package/src/cli/commands/DockerComposeCommandUtils.d.ts.map +1 -0
- package/src/cli/commands/DockerComposeCommandUtils.js +34 -0
- package/src/cli/commands/DoctorArchitectureCommand.d.ts +5 -0
- package/src/cli/commands/DoctorArchitectureCommand.d.ts.map +1 -0
- package/src/cli/commands/DoctorArchitectureCommand.js +54 -0
- package/src/cli/commands/InitContainerCommand.d.ts +5 -0
- package/src/cli/commands/InitContainerCommand.d.ts.map +1 -0
- package/src/cli/commands/InitContainerCommand.js +231 -0
- package/src/cli/commands/InitEcosystemCommand.d.ts +6 -0
- package/src/cli/commands/InitEcosystemCommand.d.ts.map +1 -0
- package/src/cli/commands/InitEcosystemCommand.js +51 -0
- package/src/cli/commands/InitProducerCommand.d.ts +5 -0
- package/src/cli/commands/InitProducerCommand.d.ts.map +1 -0
- package/src/cli/commands/InitProducerCommand.js +47 -0
- package/src/cli/commands/InitProxyCommand.d.ts +5 -0
- package/src/cli/commands/InitProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/InitProxyCommand.js +442 -0
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.js +78 -36
- package/src/cli/commands/MigrateWorkerCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateWorkerCommand.js +36 -2
- package/src/cli/commands/MongoDBProxyCommand.d.ts +5 -0
- package/src/cli/commands/MongoDBProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/MongoDBProxyCommand.js +98 -0
- package/src/cli/commands/MySqlProxyCommand.d.ts +6 -0
- package/src/cli/commands/MySqlProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/MySqlProxyCommand.js +32 -0
- package/src/cli/commands/PostgresProxyCommand.d.ts +6 -0
- package/src/cli/commands/PostgresProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/PostgresProxyCommand.js +32 -0
- package/src/cli/commands/ProxyCommand.d.ts +12 -0
- package/src/cli/commands/ProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/ProxyCommand.js +80 -0
- package/src/cli/commands/ProxyCommandUtils.d.ts +6 -0
- package/src/cli/commands/ProxyCommandUtils.d.ts.map +1 -0
- package/src/cli/commands/ProxyCommandUtils.js +38 -0
- package/src/cli/commands/PutCommand.d.ts +6 -0
- package/src/cli/commands/PutCommand.d.ts.map +1 -0
- package/src/cli/commands/PutCommand.js +173 -0
- package/src/cli/commands/QueueRecoveryCommand.d.ts +6 -0
- package/src/cli/commands/QueueRecoveryCommand.d.ts.map +1 -0
- package/src/cli/commands/QueueRecoveryCommand.js +612 -0
- package/src/cli/commands/RedisProxyCommand.d.ts +6 -0
- package/src/cli/commands/RedisProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/RedisProxyCommand.js +53 -0
- package/src/cli/commands/ScheduleListCommand.d.ts +6 -0
- package/src/cli/commands/ScheduleListCommand.d.ts.map +1 -0
- package/src/cli/commands/ScheduleListCommand.js +62 -0
- package/src/cli/commands/ScheduleRunCommand.d.ts +6 -0
- package/src/cli/commands/ScheduleRunCommand.d.ts.map +1 -0
- package/src/cli/commands/ScheduleRunCommand.js +32 -0
- package/src/cli/commands/ScheduleStartCommand.d.ts +6 -0
- package/src/cli/commands/ScheduleStartCommand.d.ts.map +1 -0
- package/src/cli/commands/ScheduleStartCommand.js +40 -0
- package/src/cli/commands/SecretsCommand.d.ts.map +1 -1
- package/src/cli/commands/SecretsCommand.js +2 -2
- package/src/cli/commands/SmtpProxyCommand.d.ts +6 -0
- package/src/cli/commands/SmtpProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/SmtpProxyCommand.js +56 -0
- package/src/cli/commands/SqlProxyCommandUtils.d.ts +46 -0
- package/src/cli/commands/SqlProxyCommandUtils.d.ts.map +1 -0
- package/src/cli/commands/SqlProxyCommandUtils.js +48 -0
- package/src/cli/commands/SqlServerProxyCommand.d.ts +5 -0
- package/src/cli/commands/SqlServerProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/SqlServerProxyCommand.js +85 -0
- package/src/cli/commands/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +132 -17
- package/src/cli/commands/WorkerCommands.d.ts +1 -0
- package/src/cli/commands/WorkerCommands.d.ts.map +1 -1
- package/src/cli/commands/WorkerCommands.js +140 -6
- package/src/cli/commands/index.d.ts +2 -0
- package/src/cli/commands/index.d.ts.map +1 -1
- package/src/cli/commands/index.js +2 -0
- package/src/cli/commands/runner/index.d.ts +2 -2
- package/src/cli/commands/runner/index.d.ts.map +1 -1
- package/src/cli/commands/runner/index.js +15 -4
- package/src/cli/commands/schedule/ScheduleCliSupport.d.ts +6 -0
- package/src/cli/commands/schedule/ScheduleCliSupport.d.ts.map +1 -0
- package/src/cli/commands/schedule/ScheduleCliSupport.js +55 -0
- package/src/cli/config/ConfigManager.d.ts.map +1 -1
- package/src/cli/config/ConfigManager.js +8 -1
- package/src/cli/d1/D1SqlMigrations.d.ts.map +1 -1
- package/src/cli/d1/D1SqlMigrations.js +14 -1
- package/src/cli/d1/WranglerConfig.d.ts.map +1 -1
- package/src/cli/d1/WranglerConfig.js +34 -2
- package/src/cli/index.d.ts +4 -0
- package/src/cli/index.d.ts.map +1 -1
- package/src/cli/index.js +4 -0
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +2 -0
- package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ServiceScaffolder.js +1 -0
- package/src/cli/services/VersionChecker.d.ts.map +1 -1
- package/src/cli/services/VersionChecker.js +5 -1
- package/src/cli/utils/DatabaseCliUtils.d.ts.map +1 -1
- package/src/cli/utils/DatabaseCliUtils.js +6 -1
- package/src/cli/utils/EnvFileLoader.d.ts.map +1 -1
- package/src/cli/utils/EnvFileLoader.js +35 -15
- package/src/cli/workers/QueueWorkRunner.js +1 -1
- package/src/cli.d.ts +5 -0
- package/src/cli.d.ts.map +1 -0
- package/src/cli.js +4 -0
- package/src/collections/index.d.ts +2 -2
- package/src/collections/index.d.ts.map +1 -1
- package/src/collections/index.js +1 -1
- package/src/common/HealthRoutes.d.ts.map +1 -1
- package/src/common/HealthRoutes.js +50 -2
- package/src/common/RemoteSignedJson.d.ts +1 -0
- package/src/common/RemoteSignedJson.d.ts.map +1 -1
- package/src/common/RemoteSignedJson.js +81 -29
- package/src/common/index.d.ts +1 -0
- package/src/common/index.d.ts.map +1 -1
- package/src/common/index.js +12 -1
- package/src/common/utility.d.ts.map +1 -1
- package/src/common/utility.js +2 -6
- package/src/config/FileLogWriter.d.ts.map +1 -1
- package/src/config/FileLogWriter.js +21 -6
- package/src/config/app.d.ts +4 -0
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +4 -0
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cache.js +22 -2
- package/src/config/cloudflare.d.ts +5 -1
- package/src/config/cloudflare.d.ts.map +1 -1
- package/src/config/cloudflare.js +67 -8
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +48 -13
- package/src/config/env.d.ts +87 -2
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +158 -19
- package/src/config/index.d.ts +1 -0
- package/src/config/index.d.ts.map +1 -1
- package/src/config/mail.d.ts.map +1 -1
- package/src/config/mail.js +16 -10
- package/src/config/middleware.d.ts +5 -0
- package/src/config/middleware.d.ts.map +1 -1
- package/src/config/middleware.js +19 -1
- package/src/config/queue.d.ts.map +1 -1
- package/src/config/queue.js +70 -9
- package/src/config/redis.d.ts.map +1 -1
- package/src/config/redis.js +48 -13
- package/src/config/storage.d.ts.map +1 -1
- package/src/config/storage.js +1 -0
- package/src/config/type.d.ts +18 -0
- package/src/config/type.d.ts.map +1 -1
- package/src/config/workers.d.ts.map +1 -1
- package/src/config/workers.js +122 -16
- package/src/functions/cloudflare.d.ts.map +1 -1
- package/src/functions/cloudflare.js +55 -1
- package/src/health/StartupHealthChecks.js +1 -1
- package/src/helper/index.d.ts +225 -0
- package/src/helper/index.d.ts.map +1 -0
- package/src/helper/index.js +347 -0
- package/src/http/FileUpload.d.ts +3 -2
- package/src/http/FileUpload.d.ts.map +1 -1
- package/src/http/Kernel.d.ts.map +1 -1
- package/src/http/Kernel.js +2 -1
- package/src/http/error-pages/ErrorPageRenderer.d.ts +4 -0
- package/src/http/error-pages/ErrorPageRenderer.d.ts.map +1 -1
- package/src/http/error-pages/ErrorPageRenderer.js +141 -1
- package/src/http/middleware/BodyParsingMiddleware.d.ts.map +1 -1
- package/src/http/middleware/BodyParsingMiddleware.js +33 -6
- package/src/index.d.ts +26 -57
- package/src/index.d.ts.map +1 -1
- package/src/index.js +32 -18
- package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -1
- package/src/microservices/ServiceAuthMiddleware.js +12 -4
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
- package/src/middleware/CsrfMiddleware.js +30 -16
- package/src/middleware/ErrorHandlerMiddleware.d.ts.map +1 -1
- package/src/middleware/ErrorHandlerMiddleware.js +2 -1
- package/src/migrations/MigrationDiscovery.d.ts.map +1 -1
- package/src/migrations/MigrationDiscovery.js +2 -1
- package/src/migrations/MigrationLoader.js +1 -1
- package/src/migrations/schema/SchemaCompiler.d.ts.map +1 -1
- package/src/migrations/schema/SchemaCompiler.js +6 -3
- package/src/node-singletons/crypto.d.ts +1 -1
- package/src/node-singletons/crypto.d.ts.map +1 -1
- package/src/node-singletons/crypto.js +1 -1
- package/src/node-singletons/fs.d.ts +1 -1
- package/src/node-singletons/fs.d.ts.map +1 -1
- package/src/node-singletons/path.d.ts +1 -1
- package/src/node-singletons/path.d.ts.map +1 -1
- package/src/node-singletons/path.js +1 -1
- package/src/node-singletons/stream.d.ts +11 -0
- package/src/node-singletons/stream.d.ts.map +1 -0
- package/src/node-singletons/stream.js +8 -0
- package/src/observability/OpenTelemetry.d.ts +7 -0
- package/src/observability/OpenTelemetry.d.ts.map +1 -1
- package/src/observability/OpenTelemetry.js +49 -2
- package/src/orm/Database.d.ts +4 -0
- package/src/orm/Database.d.ts.map +1 -1
- package/src/orm/Database.js +80 -9
- package/src/orm/DatabaseAdapter.d.ts +1 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -1
- package/src/orm/DatabaseRuntimeRegistration.d.ts.map +1 -1
- package/src/orm/DatabaseRuntimeRegistration.js +2 -0
- package/src/orm/QueryBuilder.d.ts +1 -0
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +33 -3
- package/src/orm/SchemaCompiler.d.ts.map +1 -1
- package/src/orm/SchemaCompiler.js +6 -3
- package/src/orm/SchemaStatemenWriter.d.ts +15 -0
- package/src/orm/SchemaStatemenWriter.d.ts.map +1 -0
- package/src/orm/SchemaStatemenWriter.js +78 -0
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
- package/src/orm/adapters/D1Adapter.js +52 -2
- package/src/orm/adapters/D1RemoteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/D1RemoteAdapter.js +150 -89
- package/src/orm/adapters/MongoDBProxyAdapter.d.ts +3 -0
- package/src/orm/adapters/MongoDBProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/MongoDBProxyAdapter.js +128 -0
- package/src/orm/adapters/MySQLProxyAdapter.d.ts +11 -0
- package/src/orm/adapters/MySQLProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/MySQLProxyAdapter.js +162 -0
- package/src/orm/adapters/PostgreSQLProxyAdapter.d.ts +11 -0
- package/src/orm/adapters/PostgreSQLProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/PostgreSQLProxyAdapter.js +163 -0
- package/src/orm/adapters/ProxyCache.d.ts +9 -0
- package/src/orm/adapters/ProxyCache.d.ts.map +1 -0
- package/src/orm/adapters/ProxyCache.js +24 -0
- package/src/orm/adapters/ProxySignedRequest.d.ts +11 -0
- package/src/orm/adapters/ProxySignedRequest.d.ts.map +1 -0
- package/src/orm/adapters/ProxySignedRequest.js +30 -0
- package/src/orm/adapters/ProxySigningPath.d.ts +3 -0
- package/src/orm/adapters/ProxySigningPath.d.ts.map +1 -0
- package/src/orm/adapters/ProxySigningPath.js +25 -0
- package/src/orm/adapters/SqlProxyAdapterUtils.d.ts +19 -0
- package/src/orm/adapters/SqlProxyAdapterUtils.d.ts.map +1 -0
- package/src/orm/adapters/SqlProxyAdapterUtils.js +36 -0
- package/src/orm/adapters/SqlProxyRegistryMode.d.ts +12 -0
- package/src/orm/adapters/SqlProxyRegistryMode.d.ts.map +1 -0
- package/src/orm/adapters/SqlProxyRegistryMode.js +24 -0
- package/src/orm/adapters/SqlServerProxyAdapter.d.ts +6 -0
- package/src/orm/adapters/SqlServerProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/SqlServerProxyAdapter.js +154 -0
- package/src/orm/migrations/MigrationStore.js +1 -1
- package/src/performance/Optimizer.d.ts +1 -0
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +21 -8
- package/src/proxy/ErrorHandler.d.ts +11 -0
- package/src/proxy/ErrorHandler.d.ts.map +1 -0
- package/src/proxy/ErrorHandler.js +7 -0
- package/src/proxy/PoolManager.d.ts +8 -0
- package/src/proxy/PoolManager.d.ts.map +1 -0
- package/src/proxy/PoolManager.js +18 -0
- package/src/proxy/ProxyBackend.d.ts +18 -0
- package/src/proxy/ProxyBackend.d.ts.map +1 -0
- package/src/proxy/ProxyBackend.js +1 -0
- package/src/proxy/ProxyConfig.d.ts +12 -0
- package/src/proxy/ProxyConfig.d.ts.map +1 -0
- package/src/proxy/ProxyConfig.js +1 -0
- package/src/proxy/ProxyRegistry.d.ts +10 -0
- package/src/proxy/ProxyRegistry.d.ts.map +1 -0
- package/src/proxy/ProxyRegistry.js +11 -0
- package/src/proxy/ProxyRequestParsing.d.ts +9 -0
- package/src/proxy/ProxyRequestParsing.d.ts.map +1 -0
- package/src/proxy/ProxyRequestParsing.js +16 -0
- package/src/proxy/ProxyServer.d.ts +21 -0
- package/src/proxy/ProxyServer.d.ts.map +1 -0
- package/src/proxy/ProxyServer.js +84 -0
- package/src/proxy/ProxyServerUtils.d.ts +37 -0
- package/src/proxy/ProxyServerUtils.d.ts.map +1 -0
- package/src/proxy/ProxyServerUtils.js +42 -0
- package/src/proxy/ProxySigningConfigResolver.d.ts +22 -0
- package/src/proxy/ProxySigningConfigResolver.d.ts.map +1 -0
- package/src/proxy/ProxySigningConfigResolver.js +24 -0
- package/src/proxy/ProxySigningRequest.d.ts +12 -0
- package/src/proxy/ProxySigningRequest.d.ts.map +1 -0
- package/src/proxy/ProxySigningRequest.js +31 -0
- package/src/proxy/RequestValidator.d.ts +15 -0
- package/src/proxy/RequestValidator.d.ts.map +1 -0
- package/src/proxy/RequestValidator.js +26 -0
- package/src/proxy/SigningService.d.ts +39 -0
- package/src/proxy/SigningService.d.ts.map +1 -0
- package/src/proxy/SigningService.js +107 -0
- package/src/proxy/SqlPayloadValidator.d.ts +13 -0
- package/src/proxy/SqlPayloadValidator.d.ts.map +1 -0
- package/src/proxy/SqlPayloadValidator.js +14 -0
- package/src/proxy/SqlProxyDbOverrides.d.ts +17 -0
- package/src/proxy/SqlProxyDbOverrides.d.ts.map +1 -0
- package/src/proxy/SqlProxyDbOverrides.js +1 -0
- package/src/proxy/SqlProxyServerDeps.d.ts +12 -0
- package/src/proxy/SqlProxyServerDeps.d.ts.map +1 -0
- package/src/proxy/SqlProxyServerDeps.js +9 -0
- package/src/proxy/StatementPayloadValidator.d.ts +13 -0
- package/src/proxy/StatementPayloadValidator.d.ts.map +1 -0
- package/src/proxy/StatementPayloadValidator.js +18 -0
- package/src/proxy/StatementRegistryLoader.d.ts +2 -0
- package/src/proxy/StatementRegistryLoader.d.ts.map +1 -0
- package/src/proxy/StatementRegistryLoader.js +36 -0
- package/src/proxy/StatementRegistryResolver.d.ts +15 -0
- package/src/proxy/StatementRegistryResolver.d.ts.map +1 -0
- package/src/proxy/StatementRegistryResolver.js +34 -0
- package/src/proxy/d1/ZintrustD1Proxy.d.ts +3 -0
- package/src/proxy/d1/ZintrustD1Proxy.d.ts.map +1 -0
- package/src/proxy/d1/ZintrustD1Proxy.js +2 -0
- package/src/proxy/d1/register.d.ts +2 -0
- package/src/proxy/d1/register.d.ts.map +1 -0
- package/src/proxy/d1/register.js +5 -0
- package/src/proxy/isMutatingSql.d.ts +2 -0
- package/src/proxy/isMutatingSql.d.ts.map +1 -0
- package/src/proxy/isMutatingSql.js +12 -0
- package/src/proxy/kv/ZintrustKvProxy.d.ts +3 -0
- package/src/proxy/kv/ZintrustKvProxy.d.ts.map +1 -0
- package/src/proxy/kv/ZintrustKvProxy.js +2 -0
- package/src/proxy/kv/register.d.ts +2 -0
- package/src/proxy/kv/register.d.ts.map +1 -0
- package/src/proxy/kv/register.js +5 -0
- package/src/proxy/mongodb/MongoDBProxyServer.d.ts +33 -0
- package/src/proxy/mongodb/MongoDBProxyServer.d.ts.map +1 -0
- package/src/proxy/mongodb/MongoDBProxyServer.js +202 -0
- package/src/proxy/mongodb/register.d.ts +2 -0
- package/src/proxy/mongodb/register.d.ts.map +1 -0
- package/src/proxy/mongodb/register.js +5 -0
- package/src/proxy/mysql/MySqlProxyServer.d.ts +8 -0
- package/src/proxy/mysql/MySqlProxyServer.d.ts.map +1 -0
- package/src/proxy/mysql/MySqlProxyServer.js +202 -0
- package/src/proxy/mysql/register.d.ts +2 -0
- package/src/proxy/mysql/register.d.ts.map +1 -0
- package/src/proxy/mysql/register.js +5 -0
- package/src/proxy/postgres/PostgresProxyServer.d.ts +8 -0
- package/src/proxy/postgres/PostgresProxyServer.d.ts.map +1 -0
- package/src/proxy/postgres/PostgresProxyServer.js +178 -0
- package/src/proxy/postgres/register.d.ts +2 -0
- package/src/proxy/postgres/register.d.ts.map +1 -0
- package/src/proxy/postgres/register.js +5 -0
- package/src/proxy/redis/RedisProxyServer.d.ts +12 -0
- package/src/proxy/redis/RedisProxyServer.d.ts.map +1 -0
- package/src/proxy/redis/RedisProxyServer.js +192 -0
- package/src/proxy/redis/register.d.ts +2 -0
- package/src/proxy/redis/register.d.ts.map +1 -0
- package/src/proxy/redis/register.js +5 -0
- package/src/proxy/smtp/SmtpProxyServer.d.ts +19 -0
- package/src/proxy/smtp/SmtpProxyServer.d.ts.map +1 -0
- package/src/proxy/smtp/SmtpProxyServer.js +290 -0
- package/src/proxy/smtp/register.d.ts +2 -0
- package/src/proxy/smtp/register.d.ts.map +1 -0
- package/src/proxy/smtp/register.js +5 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.d.ts +8 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.d.ts.map +1 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.js +203 -0
- package/src/proxy/sqlserver/register.d.ts +2 -0
- package/src/proxy/sqlserver/register.d.ts.map +1 -0
- package/src/proxy/sqlserver/register.js +5 -0
- package/src/proxy.d.ts +4 -0
- package/src/proxy.d.ts.map +1 -0
- package/src/proxy.js +3 -0
- package/src/routes/doc.d.ts.map +1 -1
- package/src/routes/doc.js +16 -2
- package/src/routes/error.d.ts +5 -4
- package/src/routes/error.d.ts.map +1 -1
- package/src/routes/error.js +15 -13
- package/src/routes/errorPages.d.ts +2 -0
- package/src/routes/errorPages.d.ts.map +1 -1
- package/src/routes/errorPages.js +144 -4
- package/src/runtime/PluginAutoImports.d.ts +1 -0
- package/src/runtime/PluginAutoImports.d.ts.map +1 -1
- package/src/runtime/PluginAutoImports.js +94 -9
- package/src/runtime/RuntimeAdapter.d.ts +8 -9
- package/src/runtime/RuntimeAdapter.d.ts.map +1 -1
- package/src/runtime/RuntimeAdapter.js +120 -34
- package/src/runtime/RuntimeServices.d.ts +47 -0
- package/src/runtime/RuntimeServices.d.ts.map +1 -0
- package/src/runtime/RuntimeServices.js +164 -0
- package/src/runtime/StartupConfigFileRegistry.d.ts +4 -4
- package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -1
- package/src/runtime/StartupConfigFileRegistry.js +12 -0
- package/src/runtime/WorkerAdapterImports.d.ts +5 -0
- package/src/runtime/WorkerAdapterImports.d.ts.map +1 -0
- package/src/runtime/WorkerAdapterImports.js +17 -0
- package/src/runtime/WorkersModule.d.ts +6 -0
- package/src/runtime/WorkersModule.d.ts.map +1 -0
- package/src/runtime/WorkersModule.js +278 -0
- package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/CloudflareAdapter.js +19 -2
- package/src/runtime/adapters/DenoAdapter.js +1 -0
- package/src/runtime/adapters/FargateAdapter.js +1 -1
- package/src/runtime/adapters/LambdaAdapter.js +1 -1
- package/src/runtime/adapters/NodeServerAdapter.js +1 -1
- package/src/runtime/detectRuntime.d.ts +10 -0
- package/src/runtime/detectRuntime.d.ts.map +1 -0
- package/src/runtime/detectRuntime.js +57 -0
- package/src/runtime/useFileLoader.d.ts.map +1 -1
- package/src/runtime/useFileLoader.js +16 -0
- package/src/scheduler/Schedule.d.ts +36 -0
- package/src/scheduler/Schedule.d.ts.map +1 -0
- package/src/scheduler/Schedule.js +197 -0
- package/src/scheduler/ScheduleHttpGateway.d.ts +8 -0
- package/src/scheduler/ScheduleHttpGateway.d.ts.map +1 -0
- package/src/scheduler/ScheduleHttpGateway.js +196 -0
- package/src/scheduler/ScheduleRunner.d.ts +6 -0
- package/src/scheduler/ScheduleRunner.d.ts.map +1 -1
- package/src/scheduler/ScheduleRunner.js +166 -29
- package/src/scheduler/SchedulerRuntime.d.ts +15 -0
- package/src/scheduler/SchedulerRuntime.d.ts.map +1 -0
- package/src/scheduler/SchedulerRuntime.js +79 -0
- package/src/scheduler/cron/Cron.d.ts +19 -0
- package/src/scheduler/cron/Cron.d.ts.map +1 -0
- package/src/scheduler/cron/Cron.js +200 -0
- package/src/scheduler/leader/SchedulerLeader.d.ts +14 -0
- package/src/scheduler/leader/SchedulerLeader.d.ts.map +1 -0
- package/src/scheduler/leader/SchedulerLeader.js +187 -0
- package/src/scheduler/state/ScheduleStateStore.d.ts +27 -0
- package/src/scheduler/state/ScheduleStateStore.d.ts.map +1 -0
- package/src/scheduler/state/ScheduleStateStore.js +27 -0
- package/src/scheduler/types.d.ts +10 -0
- package/src/scheduler/types.d.ts.map +1 -1
- package/src/schedules/index.d.ts +1 -0
- package/src/schedules/index.d.ts.map +1 -1
- package/src/schedules/index.js +1 -0
- package/src/schedules/job-tracking-cleanup.d.ts +4 -0
- package/src/schedules/job-tracking-cleanup.d.ts.map +1 -0
- package/src/schedules/job-tracking-cleanup.js +116 -0
- package/src/schedules/log-cleanup.d.ts +1 -2
- package/src/schedules/log-cleanup.d.ts.map +1 -1
- package/src/schedules/log-cleanup.js +12 -15
- package/src/scripts/TemplateImportsCheck.js +2 -2
- package/src/scripts/TemplateSync.js +3 -4
- package/src/security/CsrfTokenManager.d.ts.map +1 -1
- package/src/security/CsrfTokenManager.js +12 -0
- package/src/security/Hash.d.ts +1 -1
- package/src/security/Hash.d.ts.map +1 -1
- package/src/security/Hash.js +31 -36
- package/src/security/Sanitizer.d.ts.map +1 -1
- package/src/security/Sanitizer.js +1 -9
- package/src/security/SignedRequest.d.ts.map +1 -1
- package/src/security/SignedRequest.js +2 -2
- package/src/seeders/SeederLoader.js +1 -1
- package/src/session/SessionManager.d.ts +3 -0
- package/src/session/SessionManager.d.ts.map +1 -1
- package/src/session/SessionManager.js +49 -10
- package/src/sockets/CloudflareSocket.d.ts +24 -0
- package/src/sockets/CloudflareSocket.d.ts.map +1 -0
- package/src/sockets/CloudflareSocket.js +259 -0
- package/src/start.d.ts.map +1 -1
- package/src/start.js +1 -8
- package/src/templates/docker/docker-compose.ecosystem.yml.tpl +301 -0
- package/src/templates/docker/docker-compose.schedules.yml.tpl +84 -0
- package/src/templates/project/basic/app/Schedules/index.ts.tpl +0 -0
- package/src/templates/project/basic/config/database.ts.tpl +1 -1
- package/src/templates/project/basic/src/zintrust.plugins.wg.ts.tpl +8 -0
- package/src/toolkit/Secrets/Manifest.d.ts.map +1 -1
- package/src/toolkit/Secrets/Manifest.js +5 -7
- package/src/tools/mail/drivers/Smtp.d.ts.map +1 -1
- package/src/tools/mail/drivers/Smtp.js +229 -18
- package/src/tools/mail/index.d.ts.map +1 -1
- package/src/tools/mail/index.js +5 -4
- package/src/tools/mail/template-loader.d.ts.map +1 -1
- package/src/tools/mail/template-loader.js +197 -29
- package/src/tools/mail/templates/auth-password-reset.d.ts +3 -0
- package/src/tools/mail/templates/auth-password-reset.d.ts.map +1 -0
- package/src/tools/mail/templates/auth-password-reset.js +231 -0
- package/src/tools/mail/templates/auth-welcome.d.ts +3 -0
- package/src/tools/mail/templates/auth-welcome.d.ts.map +1 -0
- package/src/tools/mail/templates/auth-welcome.js +236 -0
- package/src/tools/mail/templates/general.d.ts +3 -0
- package/src/tools/mail/templates/general.d.ts.map +1 -0
- package/src/tools/mail/templates/general.js +109 -0
- package/src/tools/mail/templates/index.js +2 -2
- package/src/tools/mail/templates/job-completed.d.ts +3 -0
- package/src/tools/mail/templates/job-completed.d.ts.map +1 -0
- package/src/tools/mail/templates/job-completed.js +188 -0
- package/src/tools/mail/templates/notifications-new-comment.d.ts +3 -0
- package/src/tools/mail/templates/notifications-new-comment.d.ts.map +1 -0
- package/src/tools/mail/templates/notifications-new-comment.js +228 -0
- package/src/tools/mail/templates/password-reset.d.ts +3 -0
- package/src/tools/mail/templates/password-reset.d.ts.map +1 -0
- package/src/tools/mail/templates/password-reset.js +221 -0
- package/src/tools/mail/templates/performance-report.d.ts +3 -0
- package/src/tools/mail/templates/performance-report.d.ts.map +1 -0
- package/src/tools/mail/templates/performance-report.js +258 -0
- package/src/tools/mail/templates/welcome.d.ts +3 -0
- package/src/tools/mail/templates/welcome.d.ts.map +1 -0
- package/src/tools/mail/templates/welcome.js +187 -0
- package/src/tools/mail/templates/worker-alert.d.ts +3 -0
- package/src/tools/mail/templates/worker-alert.d.ts.map +1 -0
- package/src/tools/mail/templates/worker-alert.js +229 -0
- package/src/tools/notification/Notification.js +1 -1
- package/src/tools/notification/testingHelpers.js +6 -5
- package/src/tools/queue/AdvancedQueue.js +2 -6
- package/src/tools/queue/IdempotencyManager.d.ts +6 -0
- package/src/tools/queue/IdempotencyManager.d.ts.map +1 -0
- package/src/tools/queue/IdempotencyManager.js +36 -0
- package/src/tools/queue/JobHeartbeatStore.d.ts +16 -0
- package/src/tools/queue/JobHeartbeatStore.d.ts.map +1 -0
- package/src/tools/queue/JobHeartbeatStore.js +67 -0
- package/src/tools/queue/JobReconciliationRunner.d.ts +16 -0
- package/src/tools/queue/JobReconciliationRunner.d.ts.map +1 -0
- package/src/tools/queue/JobReconciliationRunner.js +56 -0
- package/src/tools/queue/JobRecoveryDaemon.d.ts +27 -0
- package/src/tools/queue/JobRecoveryDaemon.d.ts.map +1 -0
- package/src/tools/queue/JobRecoveryDaemon.js +303 -0
- package/src/tools/queue/JobStateTracker.d.ts +140 -0
- package/src/tools/queue/JobStateTracker.d.ts.map +1 -0
- package/src/tools/queue/JobStateTracker.js +409 -0
- package/src/tools/queue/JobStateTrackerDbPersistence.d.ts +12 -0
- package/src/tools/queue/JobStateTrackerDbPersistence.d.ts.map +1 -0
- package/src/tools/queue/JobStateTrackerDbPersistence.js +239 -0
- package/src/tools/queue/Queue.d.ts.map +1 -1
- package/src/tools/queue/Queue.js +160 -16
- package/src/tools/queue/QueueDataRedactor.d.ts +6 -0
- package/src/tools/queue/QueueDataRedactor.d.ts.map +1 -0
- package/src/tools/queue/QueueDataRedactor.js +45 -0
- package/src/tools/queue/QueueExtensions.d.ts.map +1 -1
- package/src/tools/queue/QueueExtensions.js +2 -1
- package/src/tools/queue/QueueReliabilityMetrics.d.ts +38 -0
- package/src/tools/queue/QueueReliabilityMetrics.d.ts.map +1 -0
- package/src/tools/queue/QueueReliabilityMetrics.js +131 -0
- package/src/tools/queue/QueueReliabilityOrchestrator.d.ts +7 -0
- package/src/tools/queue/QueueReliabilityOrchestrator.d.ts.map +1 -0
- package/src/tools/queue/QueueReliabilityOrchestrator.js +59 -0
- package/src/tools/queue/QueueRuntimeRegistration.d.ts +1 -9
- package/src/tools/queue/QueueRuntimeRegistration.d.ts.map +1 -1
- package/src/tools/queue/QueueRuntimeRegistration.js +75 -4
- package/src/tools/queue/QueueTracing.d.ts +32 -0
- package/src/tools/queue/QueueTracing.d.ts.map +1 -0
- package/src/tools/queue/QueueTracing.js +151 -0
- package/src/tools/queue/StalledJobMonitor.d.ts +5 -0
- package/src/tools/queue/StalledJobMonitor.d.ts.map +1 -0
- package/src/tools/queue/StalledJobMonitor.js +21 -0
- package/src/tools/queue/TimeoutManager.d.ts +14 -0
- package/src/tools/queue/TimeoutManager.d.ts.map +1 -0
- package/src/tools/queue/TimeoutManager.js +77 -0
- package/src/tools/queue/drivers/Redis.d.ts +1 -0
- package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
- package/src/tools/queue/drivers/Redis.js +1 -0
- package/src/tools/queue/index.d.ts +10 -0
- package/src/tools/queue/index.d.ts.map +1 -1
- package/src/tools/queue/index.js +10 -0
- package/src/tools/storage/drivers/R2.d.ts +13 -0
- package/src/tools/storage/drivers/R2.d.ts.map +1 -1
- package/src/tools/storage/drivers/R2.js +29 -0
- package/src/zintrust.plugins.d.ts +9 -0
- package/src/zintrust.plugins.d.ts.map +1 -0
- package/src/zintrust.plugins.js +7 -0
- package/src/zintrust.plugins.wg.d.ts +9 -0
- package/src/zintrust.plugins.wg.d.ts.map +1 -0
- package/src/zintrust.plugins.wg.js +7 -0
package/src/tools/queue/Queue.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { generateUuid } from '../../common/utility.js';
|
|
1
2
|
import { ZintrustLang } from '../../lang/lang.js';
|
|
2
3
|
import { Env } from '../../config/env.js';
|
|
4
|
+
import { Logger } from '../../config/logger.js';
|
|
3
5
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
6
|
+
import { JobStateTracker } from './JobStateTracker.js';
|
|
7
|
+
import { QueueTracing } from './QueueTracing.js';
|
|
4
8
|
import { RedisKeys } from '../redis/RedisKeyManager.js';
|
|
5
9
|
let redis_key_prefix;
|
|
6
10
|
/**
|
|
@@ -15,6 +19,61 @@ export const resolveLockPrefix = () => {
|
|
|
15
19
|
return redis_key_prefix;
|
|
16
20
|
};
|
|
17
21
|
const drivers = new Map();
|
|
22
|
+
const resolveDriverName = (name) => {
|
|
23
|
+
const resolved = (name ?? Env.QUEUE_CONNECTION) || Env.QUEUE_DRIVER || ZintrustLang.INMEMORY;
|
|
24
|
+
return (resolved !== null && resolved !== undefined ? String(resolved) : ZintrustLang.INMEMORY)
|
|
25
|
+
.trim()
|
|
26
|
+
.toLowerCase();
|
|
27
|
+
};
|
|
28
|
+
const shouldPreserveExistingStatus = (queueName, jobId) => {
|
|
29
|
+
const existing = JobStateTracker.get(queueName, jobId);
|
|
30
|
+
return existing?.status === 'pending_recovery';
|
|
31
|
+
};
|
|
32
|
+
const resolveRequestedUniqueId = (payload) => {
|
|
33
|
+
if (typeof payload?.uniqueId !== 'string')
|
|
34
|
+
return undefined;
|
|
35
|
+
const normalized = payload.uniqueId.trim();
|
|
36
|
+
return normalized.length > 0 ? normalized : undefined;
|
|
37
|
+
};
|
|
38
|
+
const resolveMaxAttempts = (payload) => {
|
|
39
|
+
if (typeof payload?.attempts !== 'number' || !Number.isFinite(payload.attempts))
|
|
40
|
+
return undefined;
|
|
41
|
+
return payload.attempts > 0 ? Math.floor(payload.attempts) : undefined;
|
|
42
|
+
};
|
|
43
|
+
const resolveExpectedCompletionAt = () => {
|
|
44
|
+
return new Date(Date.now() + Math.max(1000, Env.getInt('QUEUE_JOB_TIMEOUT', 60) * 1000)).toISOString();
|
|
45
|
+
};
|
|
46
|
+
const markEnqueued = async (input) => {
|
|
47
|
+
await JobStateTracker.enqueued({
|
|
48
|
+
queueName: input.queueName,
|
|
49
|
+
jobId: input.jobId,
|
|
50
|
+
payload: input.payload,
|
|
51
|
+
maxAttempts: resolveMaxAttempts(input.payload),
|
|
52
|
+
expectedCompletionAt: resolveExpectedCompletionAt(),
|
|
53
|
+
idempotencyKey: input.requestedUniqueId,
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
const createFallbackJobId = (requestedUniqueId) => {
|
|
57
|
+
if (requestedUniqueId !== undefined)
|
|
58
|
+
return requestedUniqueId;
|
|
59
|
+
return `fallback-${generateUuid()}`;
|
|
60
|
+
};
|
|
61
|
+
const markFailedEnqueue = async (input) => {
|
|
62
|
+
const fallbackJobId = createFallbackJobId(input.requestedUniqueId);
|
|
63
|
+
await markEnqueued({
|
|
64
|
+
queueName: input.queueName,
|
|
65
|
+
jobId: fallbackJobId,
|
|
66
|
+
payload: input.payload,
|
|
67
|
+
requestedUniqueId: input.requestedUniqueId,
|
|
68
|
+
});
|
|
69
|
+
await JobStateTracker.pendingRecovery({
|
|
70
|
+
queueName: input.queueName,
|
|
71
|
+
jobId: fallbackJobId,
|
|
72
|
+
reason: 'Queue enqueue failed; marked pending recovery by core queue layer',
|
|
73
|
+
error: input.error,
|
|
74
|
+
});
|
|
75
|
+
return fallbackJobId;
|
|
76
|
+
};
|
|
18
77
|
export const Queue = Object.freeze({
|
|
19
78
|
register(name, driver) {
|
|
20
79
|
drivers.set(name.toLowerCase(), driver);
|
|
@@ -23,35 +82,120 @@ export const Queue = Object.freeze({
|
|
|
23
82
|
drivers.clear();
|
|
24
83
|
},
|
|
25
84
|
get(name) {
|
|
26
|
-
const
|
|
27
|
-
const driverName = (resolved !== null && resolved !== undefined ? String(resolved) : ZintrustLang.INMEMORY)
|
|
28
|
-
.trim()
|
|
29
|
-
.toLowerCase();
|
|
85
|
+
const driverName = resolveDriverName(name);
|
|
30
86
|
const driver = drivers.get(driverName);
|
|
31
|
-
if (!driver)
|
|
87
|
+
if (!driver) {
|
|
32
88
|
throw ErrorFactory.createConfigError(`Queue driver not registered: ${driverName}`);
|
|
89
|
+
}
|
|
33
90
|
return driver;
|
|
34
91
|
},
|
|
35
92
|
async enqueue(queue, payload, driverName) {
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
93
|
+
const resolvedDriver = resolveDriverName(driverName);
|
|
94
|
+
const requestedUniqueId = resolveRequestedUniqueId(payload);
|
|
95
|
+
try {
|
|
96
|
+
const jobId = await QueueTracing.traceOperation({
|
|
97
|
+
queueName: queue,
|
|
98
|
+
operation: 'enqueue',
|
|
99
|
+
attributes: {
|
|
100
|
+
driverName: resolvedDriver,
|
|
101
|
+
hasUniqueId: requestedUniqueId !== undefined,
|
|
102
|
+
},
|
|
103
|
+
execute: async () => {
|
|
104
|
+
const driver = Queue.get(driverName);
|
|
105
|
+
return driver.enqueue(queue, payload);
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
Logger.info('Queue enqueue succeeded', {
|
|
109
|
+
queue,
|
|
110
|
+
driver: resolvedDriver,
|
|
111
|
+
jobId,
|
|
112
|
+
requestedUniqueId,
|
|
113
|
+
});
|
|
114
|
+
if (shouldPreserveExistingStatus(queue, jobId)) {
|
|
115
|
+
Logger.warn('Queue enqueue returned job already marked pending recovery; preserving status', {
|
|
116
|
+
queue,
|
|
117
|
+
driver: resolvedDriver,
|
|
118
|
+
jobId,
|
|
119
|
+
requestedUniqueId,
|
|
120
|
+
});
|
|
121
|
+
return jobId;
|
|
122
|
+
}
|
|
123
|
+
await markEnqueued({
|
|
124
|
+
queueName: queue,
|
|
125
|
+
jobId,
|
|
126
|
+
payload,
|
|
127
|
+
requestedUniqueId,
|
|
128
|
+
});
|
|
129
|
+
return jobId;
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
const fallbackJobId = await markFailedEnqueue({
|
|
133
|
+
queueName: queue,
|
|
134
|
+
payload,
|
|
135
|
+
requestedUniqueId,
|
|
136
|
+
error,
|
|
137
|
+
});
|
|
138
|
+
Logger.warn('Queue enqueue failed', {
|
|
139
|
+
queue,
|
|
140
|
+
driver: resolvedDriver,
|
|
141
|
+
fallbackJobId,
|
|
142
|
+
requestedUniqueId,
|
|
143
|
+
error: error instanceof Error ? error.message : String(error),
|
|
144
|
+
});
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
39
147
|
},
|
|
40
148
|
async dequeue(queue, driverName) {
|
|
41
|
-
|
|
42
|
-
|
|
149
|
+
return QueueTracing.traceOperation({
|
|
150
|
+
queueName: queue,
|
|
151
|
+
operation: 'dequeue',
|
|
152
|
+
attributes: {
|
|
153
|
+
driverName: driverName ?? null,
|
|
154
|
+
},
|
|
155
|
+
execute: async () => {
|
|
156
|
+
const driver = Queue.get(driverName);
|
|
157
|
+
return driver.dequeue(queue);
|
|
158
|
+
},
|
|
159
|
+
});
|
|
43
160
|
},
|
|
44
161
|
async ack(queue, id, driverName) {
|
|
45
|
-
|
|
46
|
-
|
|
162
|
+
return QueueTracing.traceOperation({
|
|
163
|
+
queueName: queue,
|
|
164
|
+
operation: 'ack',
|
|
165
|
+
attributes: {
|
|
166
|
+
driverName: driverName ?? null,
|
|
167
|
+
},
|
|
168
|
+
execute: async () => {
|
|
169
|
+
const driver = Queue.get(driverName);
|
|
170
|
+
await driver.ack(queue, id);
|
|
171
|
+
},
|
|
172
|
+
});
|
|
47
173
|
},
|
|
48
174
|
async length(queue, driverName) {
|
|
49
|
-
|
|
50
|
-
|
|
175
|
+
return QueueTracing.traceOperation({
|
|
176
|
+
queueName: queue,
|
|
177
|
+
operation: 'length',
|
|
178
|
+
attributes: {
|
|
179
|
+
driverName: driverName ?? null,
|
|
180
|
+
},
|
|
181
|
+
execute: async () => {
|
|
182
|
+
const driver = Queue.get(driverName);
|
|
183
|
+
return driver.length(queue);
|
|
184
|
+
},
|
|
185
|
+
});
|
|
51
186
|
},
|
|
52
187
|
async drain(queue, driverName) {
|
|
53
|
-
|
|
54
|
-
|
|
188
|
+
return QueueTracing.traceOperation({
|
|
189
|
+
queueName: queue,
|
|
190
|
+
operation: 'drain',
|
|
191
|
+
attributes: {
|
|
192
|
+
driverName: driverName ?? null,
|
|
193
|
+
},
|
|
194
|
+
execute: async () => {
|
|
195
|
+
const driver = Queue.get(driverName);
|
|
196
|
+
await driver.drain(queue);
|
|
197
|
+
},
|
|
198
|
+
});
|
|
55
199
|
},
|
|
56
200
|
});
|
|
57
201
|
export default Queue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueueDataRedactor.d.ts","sourceRoot":"","sources":["../../../../src/tools/queue/QueueDataRedactor.ts"],"names":[],"mappings":"AA+CA,eAAO,MAAM,iBAAiB;oBACZ,CAAC,WAAW,CAAC,GAAG,CAAC;sBAIf,MAAM,GAAG,MAAM;EAGjC,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const SENSITIVE_KEY_PATTERN = /pass(word)?|token|secret|api[_-]?key|auth|authorization|cookie|session|credential|private[_-]?key/i;
|
|
2
|
+
const SECRET_VALUE_PATTERN = /(bearer\s+[a-z0-9._-]+|sk_[a-z0-9]{8,}|pk_[a-z0-9]{8,}|[a-f0-9]{32,})/gi;
|
|
3
|
+
const redactString = (value) => {
|
|
4
|
+
if (value.trim() === '')
|
|
5
|
+
return value;
|
|
6
|
+
return value.replace(SECRET_VALUE_PATTERN, '[REDACTED]');
|
|
7
|
+
};
|
|
8
|
+
const sanitizeValue = (value) => {
|
|
9
|
+
if (value === null || value === undefined)
|
|
10
|
+
return value;
|
|
11
|
+
if (typeof value === 'string') {
|
|
12
|
+
return redactString(value);
|
|
13
|
+
}
|
|
14
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
return value.map((item) => sanitizeValue(item));
|
|
19
|
+
}
|
|
20
|
+
if (value instanceof Date) {
|
|
21
|
+
return value.toISOString();
|
|
22
|
+
}
|
|
23
|
+
if (typeof value === 'object') {
|
|
24
|
+
const source = value;
|
|
25
|
+
const result = {};
|
|
26
|
+
for (const [key, val] of Object.entries(source)) {
|
|
27
|
+
if (SENSITIVE_KEY_PATTERN.test(key)) {
|
|
28
|
+
result[key] = '[REDACTED]';
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
result[key] = sanitizeValue(val);
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
return String(value);
|
|
36
|
+
};
|
|
37
|
+
export const QueueDataRedactor = Object.freeze({
|
|
38
|
+
sanitizePayload(payload) {
|
|
39
|
+
return sanitizeValue(payload);
|
|
40
|
+
},
|
|
41
|
+
redactText(value) {
|
|
42
|
+
return redactString(value);
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
export default QueueDataRedactor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueExtensions.d.ts","sourceRoot":"","sources":["../../../../src/tools/queue/QueueExtensions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAsB,WAAW,EAAE,MAAM,eAAe,CAAC;AAKzF,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAKlD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAWrD;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,aAAa,EACtB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"QueueExtensions.d.ts","sourceRoot":"","sources":["../../../../src/tools/queue/QueueExtensions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAsB,WAAW,EAAE,MAAM,eAAe,CAAC;AAKzF,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAKlD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAWrD;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,aAAa,EACtB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,IAAI,CAuBrD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAEvF;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE;IACvB,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAkC3C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB;IAC3B;;OAEG;uCAEgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,aAC7B,MAAM,GAChB,kBAAkB;IAOrB;;OAEG;uCAEgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,mBACvB,MAAM,QACjB,MAAM,GACX,kBAAkB;CAStB,CAAC"}
|
|
@@ -32,7 +32,8 @@ export function extendQueue(config) {
|
|
|
32
32
|
export async function enqueueAdvanced(name, payload, options = {}) {
|
|
33
33
|
if (advancedQueueRef === null) {
|
|
34
34
|
Logger.warn(`Advanced queue not initialized, falling back to standard enqueue`);
|
|
35
|
-
|
|
35
|
+
const getQueue = await Queue?.enqueue(name, payload);
|
|
36
|
+
return getQueue ?? '';
|
|
36
37
|
}
|
|
37
38
|
return advancedQueueRef.enqueue(name, payload, options);
|
|
38
39
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type QueueReliabilitySnapshot = {
|
|
2
|
+
pending: number;
|
|
3
|
+
active: number;
|
|
4
|
+
completed: number;
|
|
5
|
+
failed: number;
|
|
6
|
+
stalled: number;
|
|
7
|
+
timeout: number;
|
|
8
|
+
pendingRecovery: number;
|
|
9
|
+
deadLetter: number;
|
|
10
|
+
manualReview: number;
|
|
11
|
+
};
|
|
12
|
+
export type QueueReliabilityAlertId = 'HighJobFailureRate' | 'StalledJobsAccumulating' | 'QueueDepthGrowing' | 'ManualReviewBacklog';
|
|
13
|
+
export type QueueReliabilityAlert = {
|
|
14
|
+
id: QueueReliabilityAlertId;
|
|
15
|
+
severity: 'warning' | 'critical';
|
|
16
|
+
message: string;
|
|
17
|
+
value: number;
|
|
18
|
+
threshold: number;
|
|
19
|
+
runbook: string;
|
|
20
|
+
};
|
|
21
|
+
export type QueueReliabilityDashboardSnapshot = {
|
|
22
|
+
queueName: string;
|
|
23
|
+
generatedAt: string;
|
|
24
|
+
metrics: QueueReliabilitySnapshot & {
|
|
25
|
+
totalTracked: number;
|
|
26
|
+
queueDepth: number;
|
|
27
|
+
failureRate: number;
|
|
28
|
+
};
|
|
29
|
+
alerts: QueueReliabilityAlert[];
|
|
30
|
+
runbooks: Record<QueueReliabilityAlertId, string>;
|
|
31
|
+
};
|
|
32
|
+
export declare const QueueReliabilityMetrics: Readonly<{
|
|
33
|
+
snapshot(queueName?: string): QueueReliabilitySnapshot;
|
|
34
|
+
runbookMap(): Record<QueueReliabilityAlertId, string>;
|
|
35
|
+
dashboardSnapshot(queueName?: string): Promise<QueueReliabilityDashboardSnapshot>;
|
|
36
|
+
}>;
|
|
37
|
+
export default QueueReliabilityMetrics;
|
|
38
|
+
//# sourceMappingURL=QueueReliabilityMetrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueueReliabilityMetrics.d.ts","sourceRoot":"","sources":["../../../../src/tools/queue/QueueReliabilityMetrics.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAC/B,oBAAoB,GACpB,yBAAyB,GACzB,mBAAmB,GACnB,qBAAqB,CAAC;AAE1B,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,uBAAuB,CAAC;IAC5B,QAAQ,EAAE,SAAS,GAAG,UAAU,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,wBAAwB,GAAG;QAClC,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;CACnD,CAAC;AAwFF,eAAO,MAAM,uBAAuB;yBACb,MAAM,GAAG,wBAAwB;kBAexC,MAAM,CAAC,uBAAuB,EAAE,MAAM,CAAC;kCAIjB,MAAM,GAAG,OAAO,CAAC,iCAAiC,CAAC;EA0CvF,CAAC;AAEH,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Env } from '../../config/env.js';
|
|
2
|
+
import { JobStateTracker } from './JobStateTracker.js';
|
|
3
|
+
import { Queue } from './Queue.js';
|
|
4
|
+
const toNumber = (input, key) => input[key] ?? 0;
|
|
5
|
+
const toRate = (failed, completed) => {
|
|
6
|
+
const denominator = failed + completed;
|
|
7
|
+
if (denominator <= 0)
|
|
8
|
+
return 0;
|
|
9
|
+
return failed / denominator;
|
|
10
|
+
};
|
|
11
|
+
const resolveRunbookBase = () => {
|
|
12
|
+
const base = Env.get('JOB_RUNBOOK_BASE_URL', '/docs/runbooks').trim();
|
|
13
|
+
if (base === '')
|
|
14
|
+
return '/docs/runbooks';
|
|
15
|
+
return base.endsWith('/') ? base.slice(0, -1) : base;
|
|
16
|
+
};
|
|
17
|
+
const getRunbookMap = () => {
|
|
18
|
+
const base = resolveRunbookBase();
|
|
19
|
+
return {
|
|
20
|
+
HighJobFailureRate: `${base}/high-job-failure-rate`,
|
|
21
|
+
StalledJobsAccumulating: `${base}/stalled-jobs-accumulating`,
|
|
22
|
+
QueueDepthGrowing: `${base}/queue-depth-growing`,
|
|
23
|
+
ManualReviewBacklog: `${base}/manual-review-backlog`,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const evaluateAlerts = (queueName, metrics) => {
|
|
27
|
+
const runbooks = getRunbookMap();
|
|
28
|
+
const alerts = [];
|
|
29
|
+
const failureThreshold = Math.max(0, Env.getFloat('JOB_ALERT_FAILURE_RATE_THRESHOLD', 0.1));
|
|
30
|
+
const stalledThreshold = Math.max(1, Env.getInt('JOB_ALERT_STALLED_THRESHOLD', 50));
|
|
31
|
+
const queueDepthThreshold = Math.max(1, Env.getInt('JOB_ALERT_QUEUE_DEPTH_THRESHOLD', 1000));
|
|
32
|
+
const manualReviewThreshold = Math.max(1, Env.getInt('JOB_ALERT_MANUAL_REVIEW_THRESHOLD', 10));
|
|
33
|
+
if (metrics.failureRate > failureThreshold) {
|
|
34
|
+
alerts.push({
|
|
35
|
+
id: 'HighJobFailureRate',
|
|
36
|
+
severity: 'critical',
|
|
37
|
+
message: `Queue ${queueName} failure rate is above threshold`,
|
|
38
|
+
value: Number(metrics.failureRate.toFixed(6)),
|
|
39
|
+
threshold: failureThreshold,
|
|
40
|
+
runbook: runbooks.HighJobFailureRate,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (metrics.stalled > stalledThreshold) {
|
|
44
|
+
alerts.push({
|
|
45
|
+
id: 'StalledJobsAccumulating',
|
|
46
|
+
severity: 'critical',
|
|
47
|
+
message: `Queue ${queueName} stalled jobs exceed threshold`,
|
|
48
|
+
value: metrics.stalled,
|
|
49
|
+
threshold: stalledThreshold,
|
|
50
|
+
runbook: runbooks.StalledJobsAccumulating,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (metrics.queueDepth > queueDepthThreshold) {
|
|
54
|
+
alerts.push({
|
|
55
|
+
id: 'QueueDepthGrowing',
|
|
56
|
+
severity: 'warning',
|
|
57
|
+
message: `Queue ${queueName} depth is above threshold`,
|
|
58
|
+
value: metrics.queueDepth,
|
|
59
|
+
threshold: queueDepthThreshold,
|
|
60
|
+
runbook: runbooks.QueueDepthGrowing,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (metrics.manualReview > manualReviewThreshold) {
|
|
64
|
+
alerts.push({
|
|
65
|
+
id: 'ManualReviewBacklog',
|
|
66
|
+
severity: 'warning',
|
|
67
|
+
message: `Queue ${queueName} manual-review backlog is above threshold`,
|
|
68
|
+
value: metrics.manualReview,
|
|
69
|
+
threshold: manualReviewThreshold,
|
|
70
|
+
runbook: runbooks.ManualReviewBacklog,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return alerts;
|
|
74
|
+
};
|
|
75
|
+
export const QueueReliabilityMetrics = Object.freeze({
|
|
76
|
+
snapshot(queueName) {
|
|
77
|
+
const summary = JobStateTracker.getSummary(queueName);
|
|
78
|
+
return {
|
|
79
|
+
pending: toNumber(summary, 'pending'),
|
|
80
|
+
active: toNumber(summary, 'active'),
|
|
81
|
+
completed: toNumber(summary, 'completed'),
|
|
82
|
+
failed: toNumber(summary, 'failed'),
|
|
83
|
+
stalled: toNumber(summary, 'stalled'),
|
|
84
|
+
timeout: toNumber(summary, 'timeout'),
|
|
85
|
+
pendingRecovery: toNumber(summary, 'pending_recovery'),
|
|
86
|
+
deadLetter: toNumber(summary, 'dead_letter'),
|
|
87
|
+
manualReview: toNumber(summary, 'manual_review'),
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
runbookMap() {
|
|
91
|
+
return getRunbookMap();
|
|
92
|
+
},
|
|
93
|
+
async dashboardSnapshot(queueName) {
|
|
94
|
+
const normalizedQueueName = typeof queueName === 'string' ? queueName.trim() : '';
|
|
95
|
+
const resolvedQueueName = normalizedQueueName === ''
|
|
96
|
+
? Env.get('JOB_DASHBOARD_DEFAULT_QUEUE', 'default')
|
|
97
|
+
: normalizedQueueName;
|
|
98
|
+
const metrics = this.snapshot(resolvedQueueName);
|
|
99
|
+
let queueDepth = 0;
|
|
100
|
+
try {
|
|
101
|
+
queueDepth = await Queue.length(resolvedQueueName);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
queueDepth = 0;
|
|
105
|
+
}
|
|
106
|
+
const totalTracked = metrics.pending +
|
|
107
|
+
metrics.active +
|
|
108
|
+
metrics.completed +
|
|
109
|
+
metrics.failed +
|
|
110
|
+
metrics.stalled +
|
|
111
|
+
metrics.timeout +
|
|
112
|
+
metrics.pendingRecovery +
|
|
113
|
+
metrics.deadLetter +
|
|
114
|
+
metrics.manualReview;
|
|
115
|
+
const failureRate = toRate(metrics.failed + metrics.deadLetter, metrics.completed);
|
|
116
|
+
const derivedMetrics = {
|
|
117
|
+
...metrics,
|
|
118
|
+
totalTracked,
|
|
119
|
+
queueDepth,
|
|
120
|
+
failureRate,
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
queueName: resolvedQueueName,
|
|
124
|
+
generatedAt: new Date().toISOString(),
|
|
125
|
+
metrics: derivedMetrics,
|
|
126
|
+
alerts: evaluateAlerts(resolvedQueueName, derivedMetrics),
|
|
127
|
+
runbooks: getRunbookMap(),
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
export default QueueReliabilityMetrics;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueueReliabilityOrchestrator.d.ts","sourceRoot":"","sources":["../../../../src/tools/queue/QueueReliabilityOrchestrator.ts"],"names":[],"mappings":"AAiCA,eAAO,MAAM,4BAA4B;iBAC1B,OAAO;aAIX,IAAI;YA4BL,IAAI;EAUZ,CAAC;AAEH,eAAe,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Env } from '../../config/env.js';
|
|
2
|
+
import { Logger } from '../../config/logger.js';
|
|
3
|
+
import { JobReconciliationRunner } from './JobReconciliationRunner.js';
|
|
4
|
+
import { JobRecoveryDaemon } from './JobRecoveryDaemon.js';
|
|
5
|
+
import { StalledJobMonitor } from './StalledJobMonitor.js';
|
|
6
|
+
const state = {
|
|
7
|
+
started: false,
|
|
8
|
+
};
|
|
9
|
+
const clearTimer = (timer) => {
|
|
10
|
+
if (timer === undefined)
|
|
11
|
+
return;
|
|
12
|
+
clearInterval(timer);
|
|
13
|
+
};
|
|
14
|
+
const startInterval = (handler, intervalMs) => setInterval(() => {
|
|
15
|
+
handler().catch((error) => {
|
|
16
|
+
Logger.warn('Queue reliability interval failed', {
|
|
17
|
+
error: error instanceof Error ? error : String(error),
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}, intervalMs);
|
|
21
|
+
export const QueueReliabilityOrchestrator = Object.freeze({
|
|
22
|
+
isEnabled() {
|
|
23
|
+
return Env.getBool('JOB_RELIABILITY_ENABLED', true);
|
|
24
|
+
},
|
|
25
|
+
start() {
|
|
26
|
+
if (!this.isEnabled())
|
|
27
|
+
return;
|
|
28
|
+
if (state.started)
|
|
29
|
+
return;
|
|
30
|
+
const reconciliationMs = Math.max(5000, Env.getInt('JOB_RECONCILIATION_INTERVAL_MS', 60000));
|
|
31
|
+
const recoveryMs = Math.max(5000, Env.getInt('JOB_RECOVERY_INTERVAL_MS', 30000));
|
|
32
|
+
const stalledMs = Math.max(5000, Env.getInt('STALLED_JOB_CHECK_INTERVAL_MS', 30000));
|
|
33
|
+
state.reconciliationTimer = startInterval(async () => {
|
|
34
|
+
await JobReconciliationRunner.runOnce();
|
|
35
|
+
}, reconciliationMs);
|
|
36
|
+
state.recoveryTimer = startInterval(async () => {
|
|
37
|
+
await JobRecoveryDaemon.runOnce();
|
|
38
|
+
}, recoveryMs);
|
|
39
|
+
state.stalledTimer = startInterval(async () => {
|
|
40
|
+
await StalledJobMonitor.scanOnce();
|
|
41
|
+
}, stalledMs);
|
|
42
|
+
state.started = true;
|
|
43
|
+
Logger.info('Queue reliability orchestrator started', {
|
|
44
|
+
reconciliationMs,
|
|
45
|
+
recoveryMs,
|
|
46
|
+
stalledMs,
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
stop() {
|
|
50
|
+
clearTimer(state.reconciliationTimer);
|
|
51
|
+
clearTimer(state.recoveryTimer);
|
|
52
|
+
clearTimer(state.stalledTimer);
|
|
53
|
+
state.reconciliationTimer = undefined;
|
|
54
|
+
state.recoveryTimer = undefined;
|
|
55
|
+
state.stalledTimer = undefined;
|
|
56
|
+
state.started = false;
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
export default QueueReliabilityOrchestrator;
|
|
@@ -1,11 +1,3 @@
|
|
|
1
1
|
import type { QueueConfig } from '../../config/queue';
|
|
2
|
-
|
|
3
|
-
* Register queue drivers from runtime config.
|
|
4
|
-
*
|
|
5
|
-
* This follows the framework's config-driven availability pattern:
|
|
6
|
-
* - Built-in drivers are registered so `QUEUE_DRIVER=sync|inmemory|redis` works out of the box.
|
|
7
|
-
* - If the configured default is registered, it is ALSO registered as 'default'.
|
|
8
|
-
* - Unknown/unregistered driver names still throw when selected.
|
|
9
|
-
*/
|
|
10
|
-
export declare function registerQueuesFromRuntimeConfig(config: QueueConfig): void;
|
|
2
|
+
export declare function registerQueuesFromRuntimeConfig(config: QueueConfig): Promise<void>;
|
|
11
3
|
//# sourceMappingURL=QueueRuntimeRegistration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueRuntimeRegistration.d.ts","sourceRoot":"","sources":["../../../../src/tools/queue/QueueRuntimeRegistration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"QueueRuntimeRegistration.d.ts","sourceRoot":"","sources":["../../../../src/tools/queue/QueueRuntimeRegistration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAoFjD,wBAAsB,+BAA+B,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAyCxF"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
import { Logger } from '../../config/logger.js';
|
|
2
|
+
import { Env } from '../../config/env.js';
|
|
1
3
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
4
|
+
import { ZintrustLang } from '../../lang/lang.js';
|
|
5
|
+
import { existsSync } from '../../node-singletons/fs.js';
|
|
6
|
+
import * as path from '../../node-singletons/path.js';
|
|
7
|
+
import { pathToFileURL } from '../../node-singletons/url.js';
|
|
8
|
+
import { detectRuntime } from '../../runtime/detectRuntime.js';
|
|
2
9
|
import { DatabaseQueue } from '../queue/drivers/Database.js';
|
|
10
|
+
import { autoRegisterJobStateTrackerPersistenceFromEnv } from '../queue/JobStateTrackerDbPersistence.js';
|
|
11
|
+
import { QueueReliabilityOrchestrator } from '../queue/QueueReliabilityOrchestrator.js';
|
|
3
12
|
import { InMemoryQueue } from '../queue/drivers/InMemory.js';
|
|
4
13
|
import { Queue } from '../queue/Queue.js';
|
|
5
14
|
/**
|
|
@@ -10,16 +19,78 @@ import { Queue } from '../queue/Queue.js';
|
|
|
10
19
|
* - If the configured default is registered, it is ALSO registered as 'default'.
|
|
11
20
|
* - Unknown/unregistered driver names still throw when selected.
|
|
12
21
|
*/
|
|
13
|
-
|
|
22
|
+
const registerRedisDriverIfAvailable = async () => {
|
|
23
|
+
try {
|
|
24
|
+
const mod = (await import('@zintrust/queue-redis'));
|
|
25
|
+
if (mod.RedisQueue !== undefined) {
|
|
26
|
+
Queue.register('redis', mod.RedisQueue);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
if (mod.BullMQRedisQueue !== undefined) {
|
|
30
|
+
Queue.register('redis', mod.BullMQRedisQueue);
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Fall back to local dist build output when running inside the core repo Docker image.
|
|
36
|
+
// In that environment, `@zintrust/queue-redis` is not installed in node_modules,
|
|
37
|
+
// but the compiled package is available at `dist/packages/queue-redis`.
|
|
38
|
+
try {
|
|
39
|
+
const cwd = typeof process !== 'undefined' && typeof process.cwd === 'function' ? process.cwd() : '';
|
|
40
|
+
if (cwd.trim() === '')
|
|
41
|
+
return false;
|
|
42
|
+
const localEntry = path.join(cwd, 'dist', 'packages', 'queue-redis', 'src', 'index.js');
|
|
43
|
+
if (!existsSync(localEntry))
|
|
44
|
+
return false;
|
|
45
|
+
const url = pathToFileURL(localEntry).href;
|
|
46
|
+
const localMod = (await import(url));
|
|
47
|
+
if (localMod.RedisQueue !== undefined) {
|
|
48
|
+
Queue.register('redis', localMod.RedisQueue);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
if (localMod.BullMQRedisQueue !== undefined) {
|
|
52
|
+
Queue.register('redis', localMod.BullMQRedisQueue);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// ignore
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
};
|
|
63
|
+
export async function registerQueuesFromRuntimeConfig(config) {
|
|
64
|
+
autoRegisterJobStateTrackerPersistenceFromEnv();
|
|
14
65
|
// Built-in drivers (core)
|
|
15
66
|
Queue.register('inmemory', InMemoryQueue);
|
|
16
|
-
Queue.register(
|
|
67
|
+
Queue.register(ZintrustLang.DATABASE, DatabaseQueue);
|
|
17
68
|
// Project templates use QUEUE_DRIVER=sync; treat this as an alias of in-memory.
|
|
18
69
|
Queue.register('sync', InMemoryQueue);
|
|
19
70
|
const defaultName = (config.default ?? '').toString().trim().toLowerCase();
|
|
20
71
|
if (defaultName.length === 0) {
|
|
21
72
|
throw ErrorFactory.createConfigError('Queue default driver is not configured');
|
|
22
73
|
}
|
|
23
|
-
|
|
24
|
-
|
|
74
|
+
if (defaultName === 'redis') {
|
|
75
|
+
const registered = await registerRedisDriverIfAvailable();
|
|
76
|
+
if (!registered) {
|
|
77
|
+
throw ErrorFactory.createConfigError('Redis queue driver is not registered. Install queue:redis via zin plugin install.');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const drv = Queue.get(defaultName);
|
|
82
|
+
Queue.register('default', drv);
|
|
83
|
+
if (Env.getBool('JOB_RELIABILITY_AUTOSTART', false)) {
|
|
84
|
+
QueueReliabilityOrchestrator.start();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
const { isCloudflare } = detectRuntime();
|
|
89
|
+
if (isCloudflare) {
|
|
90
|
+
Logger.warn(`[queue] Default driver '${defaultName}' is unavailable in Cloudflare runtime; falling back to 'sync'.`);
|
|
91
|
+
Queue.register('default', Queue.get('sync'));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
throw ErrorFactory.createConfigError('Queue default driver is not available', error);
|
|
95
|
+
}
|
|
25
96
|
}
|