initial data-ingestion refactor
This commit is contained in:
parent
09d907a10c
commit
4f89affc2b
19 changed files with 309 additions and 549 deletions
|
|
@ -7,11 +7,12 @@ import {
|
|||
handlerRegistry,
|
||||
type HandlerConfigWithSchedule,
|
||||
} from '@stock-bot/queue';
|
||||
import type { ServiceContainer } from '@stock-bot/connection-factory';
|
||||
|
||||
const logger = getLogger('ib-provider');
|
||||
|
||||
// Initialize and register the IB provider
|
||||
export function initializeIBProvider() {
|
||||
export function initializeIBProvider(container: ServiceContainer) {
|
||||
logger.debug('Registering IB provider with scheduled jobs...');
|
||||
|
||||
const ibProviderConfig: HandlerConfigWithSchedule = {
|
||||
|
|
@ -21,7 +22,7 @@ export function initializeIBProvider() {
|
|||
// payload contains session configuration (not used in current implementation)
|
||||
logger.debug('Processing session fetch request');
|
||||
const { fetchSession } = await import('./operations/session.operations');
|
||||
return fetchSession();
|
||||
return fetchSession(container);
|
||||
}),
|
||||
|
||||
'fetch-exchanges': createJobHandler(async () => {
|
||||
|
|
@ -29,9 +30,9 @@ export function initializeIBProvider() {
|
|||
logger.debug('Processing exchanges fetch request');
|
||||
const { fetchSession } = await import('./operations/session.operations');
|
||||
const { fetchExchanges } = await import('./operations/exchanges.operations');
|
||||
const sessionHeaders = await fetchSession();
|
||||
const sessionHeaders = await fetchSession(container);
|
||||
if (sessionHeaders) {
|
||||
return fetchExchanges(sessionHeaders);
|
||||
return fetchExchanges(sessionHeaders, container);
|
||||
}
|
||||
throw new Error('Failed to get session headers');
|
||||
}),
|
||||
|
|
@ -41,9 +42,9 @@ export function initializeIBProvider() {
|
|||
logger.debug('Processing symbols fetch request');
|
||||
const { fetchSession } = await import('./operations/session.operations');
|
||||
const { fetchSymbols } = await import('./operations/symbols.operations');
|
||||
const sessionHeaders = await fetchSession();
|
||||
const sessionHeaders = await fetchSession(container);
|
||||
if (sessionHeaders) {
|
||||
return fetchSymbols(sessionHeaders);
|
||||
return fetchSymbols(sessionHeaders, container);
|
||||
}
|
||||
throw new Error('Failed to get session headers');
|
||||
}),
|
||||
|
|
@ -55,16 +56,16 @@ export function initializeIBProvider() {
|
|||
const { fetchExchanges } = await import('./operations/exchanges.operations');
|
||||
const { fetchSymbols } = await import('./operations/symbols.operations');
|
||||
|
||||
const sessionHeaders = await fetchSession();
|
||||
const sessionHeaders = await fetchSession(container);
|
||||
logger.info('Fetched symbol summary from IB');
|
||||
|
||||
if (sessionHeaders) {
|
||||
logger.debug('Fetching exchanges from IB');
|
||||
const exchanges = await fetchExchanges(sessionHeaders);
|
||||
const exchanges = await fetchExchanges(sessionHeaders, container);
|
||||
logger.info('Fetched exchanges from IB', { count: exchanges?.length });
|
||||
|
||||
logger.debug('Fetching symbols from IB');
|
||||
const symbols = await fetchSymbols(sessionHeaders);
|
||||
const symbols = await fetchSymbols(sessionHeaders, container);
|
||||
logger.info('Fetched symbols from IB', { symbols });
|
||||
|
||||
return { exchangesCount: exchanges?.length, symbolsCount: symbols?.length };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue