From 964b076c840f528f08f9266153b308c5616a53c4 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Sat, 18 Jul 2026 19:44:41 +0300 Subject: [PATCH] refactor(worker): declare the flusher directly instead of importing LocationsModule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit جذر العلّة وراء أعطال الـDI الأربعة: WorkerModule استورد LocationsModule كاملة، فجرّت الجيوفنس ← الإشعارات ← المستخدمين ← المستأجرين، وأربعة متحكّمات HTTP تُنشأ في عملية لا تخدم HTTP. المفرّغ يحقن Redis ومستودعَين لا غير. بإعلانه مباشرةً تسقط الحاجة إلى I18n و Cache و Entitlements التي أضفتها في الدورتين السابقتين. Co-Authored-By: Claude Opus 4.8 --- backend/src/worker.module.ts | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/backend/src/worker.module.ts b/backend/src/worker.module.ts index ffcf014..adac5a4 100644 --- a/backend/src/worker.module.ts +++ b/backend/src/worker.module.ts @@ -3,18 +3,18 @@ import { ConfigModule, ConfigService } from '@nestjs/config'; import { TypeOrmModule } from '@nestjs/typeorm'; import configuration from './config/configuration'; import { RedisModule } from './common/redis/redis.module'; -import { I18nModule } from './common/i18n/i18n.module'; -import { CacheModule } from './common/cache/cache.module'; -import { EntitlementsModule } from './common/entitlements/entitlements.module'; -import { LocationsModule } from './modules/locations/locations.module'; +import { Driver } from './modules/drivers/entities/driver.entity'; +import { DriverTrack } from './modules/locations/entities/driver-track.entity'; +import { LocationFlusherService } from './modules/locations/location-flusher.service'; /** * وحدة الـworker — عملية منفصلة (`node dist/worker.js`) لا تخدم HTTP. - * تحمل ما يحتاجه العمل الدوري فقط: قاعدة + Redis + المواقع. * - * جذر تجميع ثانٍ مستقل عن AppModule: الوحدات `@Global` تُسجَّل فقط إن - * استوردها أحدٌ في الشجرة، فما يسجّله AppModule لا يصل إلى هنا مجّاناً. - * المواقع تجرّ الجيوفنس ← الإشعارات ← i18n + cache (وعبر المستخدمين أيضاً). + * تُعلن المفرّغ مباشرةً بدل استيراد `LocationsModule`: المفرّغ يحقن Redis + * ومستودعَين لا غير، بينما الوحدة تجرّ خلفها الجيوفنس ← الإشعارات ← + * المستخدمين ← المستأجرين، وأربعة متحكّمات HTTP في عملية بلا HTTP. + * جذر التجميع هنا مستقلّ عن AppModule، فالوحدات `@Global` لا تصل مجّاناً — + * وأضيق شجرة هي أقلّها مفاجآت عند الإقلاع. */ @Module({ imports: [ @@ -36,10 +36,8 @@ import { LocationsModule } from './modules/locations/locations.module'; }), }), RedisModule, - I18nModule, // عالمي — نصوص إشعارات الجيوفنس - CacheModule, // عالمي — يحقنه UsersService خلف الإشعارات - EntitlementsModule, // عالمي — يحقنه TenantsService خلف المستخدمين - LocationsModule, + TypeOrmModule.forFeature([Driver, DriverTrack]), ], + providers: [LocationFlusherService], }) export class WorkerModule {}