refactoring

This commit is contained in:
Boki 2025-06-22 07:13:09 -04:00
parent 3fb9df425c
commit 62a2f15dab
12 changed files with 670 additions and 13 deletions

View file

@ -5,6 +5,7 @@
import type { IServiceContainer } from '@stock-bot/handlers';
import type { IDataIngestionServices } from '../service-interfaces';
import { ProxyManager } from '@stock-bot/proxy';
/**
* Adapter that converts IDataIngestionServices to IServiceContainer
@ -22,6 +23,10 @@ export class DataIngestionServiceAdapter implements IServiceContainer {
// HTTP client not in current data services - will be added when needed
return null;
}
get proxy() {
// Return singleton proxy manager instance
return ProxyManager.getInstance();
}
// Database clients
get mongodb() { return this.dataServices.mongodb; }

View file

@ -5,6 +5,7 @@
import { getLogger } from '@stock-bot/logger';
import { ConnectionFactory } from './connection-factory';
import { PoolSizeCalculator } from './pool-size-calculator';
import { ProxyManager } from '@stock-bot/proxy';
import type {
IDataIngestionServices,
IServiceFactory,
@ -44,6 +45,10 @@ export class DataIngestionServiceFactory implements IServiceFactory {
this.createQueueConnection(connectionFactory, config)
]);
// Initialize proxy manager
logger.info('Initializing proxy manager...');
await ProxyManager.initialize();
const services: IDataIngestionServices = {
mongodb: mongoPool.client,
postgres: postgresPool.client,

View file

@ -3,6 +3,8 @@
* Simple, comprehensive container with all services available
*/
import type { ProxyManager } from '@stock-bot/proxy';
/**
* Universal service container with all common services
* Designed to work across different service contexts (data-ingestion, processing, etc.)
@ -13,6 +15,7 @@ export interface IServiceContainer {
readonly cache: any; // Cache provider (Redis/Dragonfly)
readonly queue: any; // Queue manager (BullMQ)
readonly http: any; // HTTP client with proxy support
readonly proxy: ProxyManager; // Proxy manager service
// Database clients
readonly mongodb: any; // MongoDB client