initial data-ingestion refactor
This commit is contained in:
parent
09d907a10c
commit
4f89affc2b
19 changed files with 309 additions and 549 deletions
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
import { OperationContext } from '@stock-bot/utils';
|
||||
import { getRandomProxy } from '@stock-bot/utils';
|
||||
import type { ServiceContainer } from '@stock-bot/connection-factory';
|
||||
|
||||
import { QMSessionManager } from '../shared/session-manager';
|
||||
import { QM_SESSION_IDS, QM_CONFIG, SESSION_CONFIG } from '../shared/config';
|
||||
|
|
@ -11,13 +12,13 @@ import type { SymbolSpiderJob, Exchange } from '../shared/types';
|
|||
import { initializeQMResources } from './session.operations';
|
||||
import { spiderSymbolSearch } from './spider.operations';
|
||||
|
||||
export async function fetchSymbols(): Promise<unknown[] | null> {
|
||||
const ctx = OperationContext.create('qm', 'symbols');
|
||||
export async function fetchSymbols(container: ServiceContainer): Promise<unknown[] | null> {
|
||||
const ctx = OperationContext.create('qm', 'symbols', { container });
|
||||
|
||||
try {
|
||||
const sessionManager = QMSessionManager.getInstance();
|
||||
if (!sessionManager.getInitialized()) {
|
||||
await initializeQMResources();
|
||||
await initializeQMResources(container);
|
||||
}
|
||||
|
||||
ctx.logger.info('Starting QM spider-based symbol search...');
|
||||
|
|
@ -57,11 +58,13 @@ export async function fetchSymbols(): Promise<unknown[] | null> {
|
|||
} catch (error) {
|
||||
ctx.logger.error('Failed to start QM spider symbol search', { error });
|
||||
return null;
|
||||
} finally {
|
||||
await ctx.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
export async function searchQMSymbolsAPI(query: string): Promise<any[]> {
|
||||
const ctx = OperationContext.create('qm', 'api-search');
|
||||
export async function searchQMSymbolsAPI(query: string, container: ServiceContainer): Promise<any[]> {
|
||||
const ctx = OperationContext.create('qm', 'api-search', { container });
|
||||
|
||||
const proxyInfo = await getRandomProxy();
|
||||
if (!proxyInfo) {
|
||||
|
|
@ -191,5 +194,7 @@ export async function searchQMSymbolsAPI(query: string): Promise<any[]> {
|
|||
});
|
||||
|
||||
throw error;
|
||||
} finally {
|
||||
await ctx.dispose();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue