reorganized providers to handlers and changed folder structure for maintaiablity

This commit is contained in:
Boki 2025-06-21 09:53:33 -04:00
parent 1bb2380a28
commit 59ab0940ae
11 changed files with 21 additions and 21 deletions

View file

@ -74,11 +74,11 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
**Service Structure**:
- Each service has `src/index.ts` as entry point
- Routes in `src/routes/` using Hono framework
- Providers/services in `src/providers/` or `src/services/`
- Handlers/services in `src/handlers/` or `src/services/`
- Use dependency injection pattern
**Data Processing**:
- Raw data → QuestDB via providers
- Raw data → QuestDB via handlers
- Processed data → PostgreSQL via processing service
- Event-driven communication via Dragonfly
- Queue-based batch processing for large datasets

View file

@ -20,14 +20,14 @@ export function initializeIBProvider() {
'fetch-session': createJobHandler(async () => {
// payload contains session configuration (not used in current implementation)
logger.debug('Processing session fetch request');
const { fetchSession } = await import('./ib.tasks');
const { fetchSession } = await import('./ib.operations');
return fetchSession();
}),
'fetch-exchanges': createJobHandler(async () => {
// payload should contain session headers
logger.debug('Processing exchanges fetch request');
const { fetchSession, fetchExchanges } = await import('./ib.tasks');
const { fetchSession, fetchExchanges } = await import('./ib.operations');
const sessionHeaders = await fetchSession();
if (sessionHeaders) {
return fetchExchanges(sessionHeaders);
@ -38,7 +38,7 @@ export function initializeIBProvider() {
'fetch-symbols': createJobHandler(async () => {
// payload should contain session headers
logger.debug('Processing symbols fetch request');
const { fetchSession, fetchSymbols } = await import('./ib.tasks');
const { fetchSession, fetchSymbols } = await import('./ib.operations');
const sessionHeaders = await fetchSession();
if (sessionHeaders) {
return fetchSymbols(sessionHeaders);
@ -49,7 +49,7 @@ export function initializeIBProvider() {
'ib-exchanges-and-symbols': createJobHandler(async () => {
// Legacy operation for scheduled jobs
logger.info('Fetching symbol summary from IB');
const { fetchSession, fetchExchanges, fetchSymbols } = await import('./ib.tasks');
const { fetchSession, fetchExchanges, fetchSymbols } = await import('./ib.operations');
const sessionHeaders = await fetchSession();
logger.info('Fetched symbol summary from IB');

View file

@ -18,7 +18,7 @@ export function initializeProxyProvider() {
'fetch-from-sources': createJobHandler(async () => {
// Fetch proxies from all configured sources
logger.info('Processing fetch proxies from sources request');
const { fetchProxiesFromSources } = await import('./proxy.tasks');
const { fetchProxiesFromSources } = await import('./proxy.operations');
const { processItems } = await import('@stock-bot/queue');
// Fetch all proxies from sources
@ -65,7 +65,7 @@ export function initializeProxyProvider() {
logger.debug('Processing proxy check request', {
proxy: `${payload.host}:${payload.port}`,
});
const { checkProxy } = await import('./proxy.tasks');
const { checkProxy } = await import('./proxy.operations');
return checkProxy(payload);
}),
},

View file

@ -4,7 +4,7 @@ import {
handlerRegistry,
type HandlerConfigWithSchedule
} from '@stock-bot/queue';
import type { SymbolSpiderJob } from './qm.tasks';
import type { SymbolSpiderJob } from './qm.operations';
const logger = getLogger('qm-provider');
@ -17,14 +17,14 @@ export function initializeQMProvider() {
operations: {
'create-sessions': createJobHandler(async () => {
logger.debug('Creating QM sessions...');
const { createSessions } = await import('./qm.tasks');
const { createSessions } = await import('./qm.operations');
await createSessions();
logger.debug('QM sessions created successfully');
return { success: true, message: 'QM sessions created successfully' };
}),
'search-symbols': createJobHandler(async () => {
logger.info('Starting QM symbol search...');
const { fetchSymbols } = await import('./qm.tasks');
const { fetchSymbols } = await import('./qm.operations');
const symbols = await fetchSymbols();
if (symbols && symbols.length > 0) {
@ -46,7 +46,7 @@ export function initializeQMProvider() {
}),
'spider-symbol-search': createJobHandler(async (payload: SymbolSpiderJob) => {
logger.debug('Processing spider symbol search job', { payload });
const { spiderSymbolSearch } = await import('./qm.tasks');
const { spiderSymbolSearch } = await import('./qm.operations');
const result = await spiderSymbolSearch(payload);
logger.debug('Spider search job completed', {

View file

@ -21,7 +21,7 @@ export function initializeWebShareProvider() {
operations: {
'fetch-proxies': createJobHandler(async () => {
logger.info('Fetching proxies from WebShare API');
const { fetchWebShareProxies } = await import('./webshare.tasks');
const { fetchWebShareProxies } = await import('./webshare.operations');
try {
const proxies = await fetchWebShareProxies();

View file

@ -129,13 +129,13 @@ async function initializeServices() {
await ProxyManager.initialize();
logger.info('Proxy manager initialized');
// Initialize providers (register handlers and scheduled jobs)
logger.debug('Initializing data providers...');
const { initializeWebShareProvider } = await import('./providers/webshare.provider');
const { initializeExchangeSyncProvider } = await import('./providers/exchange-sync.provider');
const { initializeIBProvider } = await import('./providers/ib.provider');
const { initializeProxyProvider } = await import('./providers/proxy.provider');
const { initializeQMProvider } = await import('./providers/qm.provider');
// Initialize handlers (register handlers and scheduled jobs)
logger.debug('Initializing data handlers...');
const { initializeWebShareProvider } = await import('./handlers/webshare/webshare.handler');
const { initializeExchangeSyncProvider } = await import('./handlers/exchange-sync/exchange-sync.handler');
const { initializeIBProvider } = await import('./handlers/ib/ib.handler');
const { initializeProxyProvider } = await import('./handlers/proxy/proxy.handler');
const { initializeQMProvider } = await import('./handlers/qm/qm.handler');
initializeWebShareProvider();
initializeExchangeSyncProvider();
@ -143,7 +143,7 @@ async function initializeServices() {
initializeProxyProvider();
initializeQMProvider();
logger.info('Data providers initialized');
logger.info('Data handlers initialized');
// Create scheduled jobs from registered handlers
logger.debug('Creating scheduled jobs from registered handlers...');