work on new di system

This commit is contained in:
Boki 2025-06-21 22:30:19 -04:00
parent 4096e91e67
commit 0c77449584
11 changed files with 161 additions and 39 deletions

View file

@ -0,0 +1,48 @@
/**
* Service Adapter - Bridges specific service interfaces to generic IServiceContainer
* Allows handlers to be decoupled from specific service implementations
*/
import type { IServiceContainer } from '@stock-bot/handlers';
import type { IDataIngestionServices } from '../service-interfaces';
/**
* Adapter that converts IDataIngestionServices to IServiceContainer
* This allows handlers to use the generic container while still supporting
* the existing data-ingestion specific services
*/
export class DataIngestionServiceAdapter implements IServiceContainer {
constructor(private readonly dataServices: IDataIngestionServices) {}
// Core infrastructure
get logger() { return this.dataServices.logger; }
get cache() { return this.dataServices.cache; }
get queue() { return this.dataServices.queue; }
get http() {
// HTTP client not in current data services - will be added when needed
return null;
}
// Database clients
get mongodb() { return this.dataServices.mongodb; }
get postgres() { return this.dataServices.postgres; }
get questdb() {
// QuestDB not in current data services - will be added when needed
return null;
}
// Optional extensions
get custom() {
return {
connectionFactory: this.dataServices.connectionFactory,
// Add other data-ingestion specific services here
};
}
}
/**
* Helper function to create service container adapter
*/
export function createServiceAdapter(dataServices: IDataIngestionServices): IServiceContainer {
return new DataIngestionServiceAdapter(dataServices);
}

View file

@ -5,4 +5,5 @@ export * from './operation-context';
export * from './pool-size-calculator';
export * from './types';
export * from './service-interfaces';
export * from './service-factory';
export * from './service-factory';
export * from './adapters/service-adapter';