1.5 KiB
1.5 KiB
Current Refactoring Context
Data Ingestion Service Refactor
The project is currently undergoing a major refactoring to move away from singleton patterns to a dependency injection approach using service containers.
What's Been Done
- Created connection pool pattern with
ServiceContainer - Refactored data-ingestion service to use DI container
- Updated handlers to accept container parameter
- Added proper resource disposal with
ctx.dispose()
Migration Status
- QM handler: ✅ Fully migrated to container pattern
- IB handler: ⚠️ Partially migrated (using migration helper)
- Proxy handler: ✅ Updated to accept container
- WebShare handler: ✅ Updated to accept container
Key Patterns
- Service Container: Central DI container managing all connections
- Operation Context: Provides scoped database access within operations
- Factory Pattern: Connection factories for different databases
- Resource Disposal: Always call
ctx.dispose()after operations
Example Pattern
const ctx = OperationContext.create('handler', 'operation', { container });
try {
// Use databases through context
await ctx.mongodb.insertOne(data);
await ctx.postgres.query('...');
return { success: true };
} finally {
await ctx.dispose(); // Always cleanup
}
Next Steps
- Complete migration of remaining IB operations
- Remove migration helper once complete
- Apply same pattern to other services
- Add monitoring for connection pools