reorganized providers to handlers and changed folder structure for maintaiablity
This commit is contained in:
parent
1bb2380a28
commit
59ab0940ae
11 changed files with 21 additions and 21 deletions
|
|
@ -74,11 +74,11 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||||
**Service Structure**:
|
**Service Structure**:
|
||||||
- Each service has `src/index.ts` as entry point
|
- Each service has `src/index.ts` as entry point
|
||||||
- Routes in `src/routes/` using Hono framework
|
- 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
|
- Use dependency injection pattern
|
||||||
|
|
||||||
**Data Processing**:
|
**Data Processing**:
|
||||||
- Raw data → QuestDB via providers
|
- Raw data → QuestDB via handlers
|
||||||
- Processed data → PostgreSQL via processing service
|
- Processed data → PostgreSQL via processing service
|
||||||
- Event-driven communication via Dragonfly
|
- Event-driven communication via Dragonfly
|
||||||
- Queue-based batch processing for large datasets
|
- Queue-based batch processing for large datasets
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,14 @@ export function initializeIBProvider() {
|
||||||
'fetch-session': createJobHandler(async () => {
|
'fetch-session': createJobHandler(async () => {
|
||||||
// payload contains session configuration (not used in current implementation)
|
// payload contains session configuration (not used in current implementation)
|
||||||
logger.debug('Processing session fetch request');
|
logger.debug('Processing session fetch request');
|
||||||
const { fetchSession } = await import('./ib.tasks');
|
const { fetchSession } = await import('./ib.operations');
|
||||||
return fetchSession();
|
return fetchSession();
|
||||||
}),
|
}),
|
||||||
|
|
||||||
'fetch-exchanges': createJobHandler(async () => {
|
'fetch-exchanges': createJobHandler(async () => {
|
||||||
// payload should contain session headers
|
// payload should contain session headers
|
||||||
logger.debug('Processing exchanges fetch request');
|
logger.debug('Processing exchanges fetch request');
|
||||||
const { fetchSession, fetchExchanges } = await import('./ib.tasks');
|
const { fetchSession, fetchExchanges } = await import('./ib.operations');
|
||||||
const sessionHeaders = await fetchSession();
|
const sessionHeaders = await fetchSession();
|
||||||
if (sessionHeaders) {
|
if (sessionHeaders) {
|
||||||
return fetchExchanges(sessionHeaders);
|
return fetchExchanges(sessionHeaders);
|
||||||
|
|
@ -38,7 +38,7 @@ export function initializeIBProvider() {
|
||||||
'fetch-symbols': createJobHandler(async () => {
|
'fetch-symbols': createJobHandler(async () => {
|
||||||
// payload should contain session headers
|
// payload should contain session headers
|
||||||
logger.debug('Processing symbols fetch request');
|
logger.debug('Processing symbols fetch request');
|
||||||
const { fetchSession, fetchSymbols } = await import('./ib.tasks');
|
const { fetchSession, fetchSymbols } = await import('./ib.operations');
|
||||||
const sessionHeaders = await fetchSession();
|
const sessionHeaders = await fetchSession();
|
||||||
if (sessionHeaders) {
|
if (sessionHeaders) {
|
||||||
return fetchSymbols(sessionHeaders);
|
return fetchSymbols(sessionHeaders);
|
||||||
|
|
@ -49,7 +49,7 @@ export function initializeIBProvider() {
|
||||||
'ib-exchanges-and-symbols': createJobHandler(async () => {
|
'ib-exchanges-and-symbols': createJobHandler(async () => {
|
||||||
// Legacy operation for scheduled jobs
|
// Legacy operation for scheduled jobs
|
||||||
logger.info('Fetching symbol summary from IB');
|
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();
|
const sessionHeaders = await fetchSession();
|
||||||
logger.info('Fetched symbol summary from IB');
|
logger.info('Fetched symbol summary from IB');
|
||||||
|
|
@ -18,7 +18,7 @@ export function initializeProxyProvider() {
|
||||||
'fetch-from-sources': createJobHandler(async () => {
|
'fetch-from-sources': createJobHandler(async () => {
|
||||||
// Fetch proxies from all configured sources
|
// Fetch proxies from all configured sources
|
||||||
logger.info('Processing fetch proxies from sources request');
|
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');
|
const { processItems } = await import('@stock-bot/queue');
|
||||||
|
|
||||||
// Fetch all proxies from sources
|
// Fetch all proxies from sources
|
||||||
|
|
@ -65,7 +65,7 @@ export function initializeProxyProvider() {
|
||||||
logger.debug('Processing proxy check request', {
|
logger.debug('Processing proxy check request', {
|
||||||
proxy: `${payload.host}:${payload.port}`,
|
proxy: `${payload.host}:${payload.port}`,
|
||||||
});
|
});
|
||||||
const { checkProxy } = await import('./proxy.tasks');
|
const { checkProxy } = await import('./proxy.operations');
|
||||||
return checkProxy(payload);
|
return checkProxy(payload);
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
@ -4,7 +4,7 @@ import {
|
||||||
handlerRegistry,
|
handlerRegistry,
|
||||||
type HandlerConfigWithSchedule
|
type HandlerConfigWithSchedule
|
||||||
} from '@stock-bot/queue';
|
} from '@stock-bot/queue';
|
||||||
import type { SymbolSpiderJob } from './qm.tasks';
|
import type { SymbolSpiderJob } from './qm.operations';
|
||||||
|
|
||||||
const logger = getLogger('qm-provider');
|
const logger = getLogger('qm-provider');
|
||||||
|
|
||||||
|
|
@ -17,14 +17,14 @@ export function initializeQMProvider() {
|
||||||
operations: {
|
operations: {
|
||||||
'create-sessions': createJobHandler(async () => {
|
'create-sessions': createJobHandler(async () => {
|
||||||
logger.debug('Creating QM sessions...');
|
logger.debug('Creating QM sessions...');
|
||||||
const { createSessions } = await import('./qm.tasks');
|
const { createSessions } = await import('./qm.operations');
|
||||||
await createSessions();
|
await createSessions();
|
||||||
logger.debug('QM sessions created successfully');
|
logger.debug('QM sessions created successfully');
|
||||||
return { success: true, message: 'QM sessions created successfully' };
|
return { success: true, message: 'QM sessions created successfully' };
|
||||||
}),
|
}),
|
||||||
'search-symbols': createJobHandler(async () => {
|
'search-symbols': createJobHandler(async () => {
|
||||||
logger.info('Starting QM symbol search...');
|
logger.info('Starting QM symbol search...');
|
||||||
const { fetchSymbols } = await import('./qm.tasks');
|
const { fetchSymbols } = await import('./qm.operations');
|
||||||
const symbols = await fetchSymbols();
|
const symbols = await fetchSymbols();
|
||||||
|
|
||||||
if (symbols && symbols.length > 0) {
|
if (symbols && symbols.length > 0) {
|
||||||
|
|
@ -46,7 +46,7 @@ export function initializeQMProvider() {
|
||||||
}),
|
}),
|
||||||
'spider-symbol-search': createJobHandler(async (payload: SymbolSpiderJob) => {
|
'spider-symbol-search': createJobHandler(async (payload: SymbolSpiderJob) => {
|
||||||
logger.debug('Processing spider symbol search job', { payload });
|
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);
|
const result = await spiderSymbolSearch(payload);
|
||||||
|
|
||||||
logger.debug('Spider search job completed', {
|
logger.debug('Spider search job completed', {
|
||||||
|
|
@ -21,7 +21,7 @@ export function initializeWebShareProvider() {
|
||||||
operations: {
|
operations: {
|
||||||
'fetch-proxies': createJobHandler(async () => {
|
'fetch-proxies': createJobHandler(async () => {
|
||||||
logger.info('Fetching proxies from WebShare API');
|
logger.info('Fetching proxies from WebShare API');
|
||||||
const { fetchWebShareProxies } = await import('./webshare.tasks');
|
const { fetchWebShareProxies } = await import('./webshare.operations');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const proxies = await fetchWebShareProxies();
|
const proxies = await fetchWebShareProxies();
|
||||||
|
|
@ -129,13 +129,13 @@ async function initializeServices() {
|
||||||
await ProxyManager.initialize();
|
await ProxyManager.initialize();
|
||||||
logger.info('Proxy manager initialized');
|
logger.info('Proxy manager initialized');
|
||||||
|
|
||||||
// Initialize providers (register handlers and scheduled jobs)
|
// Initialize handlers (register handlers and scheduled jobs)
|
||||||
logger.debug('Initializing data providers...');
|
logger.debug('Initializing data handlers...');
|
||||||
const { initializeWebShareProvider } = await import('./providers/webshare.provider');
|
const { initializeWebShareProvider } = await import('./handlers/webshare/webshare.handler');
|
||||||
const { initializeExchangeSyncProvider } = await import('./providers/exchange-sync.provider');
|
const { initializeExchangeSyncProvider } = await import('./handlers/exchange-sync/exchange-sync.handler');
|
||||||
const { initializeIBProvider } = await import('./providers/ib.provider');
|
const { initializeIBProvider } = await import('./handlers/ib/ib.handler');
|
||||||
const { initializeProxyProvider } = await import('./providers/proxy.provider');
|
const { initializeProxyProvider } = await import('./handlers/proxy/proxy.handler');
|
||||||
const { initializeQMProvider } = await import('./providers/qm.provider');
|
const { initializeQMProvider } = await import('./handlers/qm/qm.handler');
|
||||||
|
|
||||||
initializeWebShareProvider();
|
initializeWebShareProvider();
|
||||||
initializeExchangeSyncProvider();
|
initializeExchangeSyncProvider();
|
||||||
|
|
@ -143,7 +143,7 @@ async function initializeServices() {
|
||||||
initializeProxyProvider();
|
initializeProxyProvider();
|
||||||
initializeQMProvider();
|
initializeQMProvider();
|
||||||
|
|
||||||
logger.info('Data providers initialized');
|
logger.info('Data handlers initialized');
|
||||||
|
|
||||||
// Create scheduled jobs from registered handlers
|
// Create scheduled jobs from registered handlers
|
||||||
logger.debug('Creating scheduled jobs from registered handlers...');
|
logger.debug('Creating scheduled jobs from registered handlers...');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue