added cache and started fixing data-service

This commit is contained in:
Bojan Kucera 2025-06-05 08:27:06 -04:00
parent 3fc123eca3
commit d0e8fd9e3f
15 changed files with 1761 additions and 98 deletions

View file

@ -12,7 +12,7 @@ loadEnvVariables();
const app = new Hono();
const logger = createLogger('data-service');
const PORT = parseInt(process.env.DATA_SERVICE_PORT || '3002');
logger.info(`Data Service starting on port ${PORT}`);
// Health check endpoint
app.get('/health', (c) => {
return c.json({

View file

@ -51,10 +51,7 @@ export class UnifiedDataProvider implements DataProvider {
// Initialize QuestDB client
if (config.questdb) {
this.questdb = new QuestDBClient({
host: config.questdb.host,
port: config.questdb.port
});
this.questdb = new QuestDBClient();
}
this.initializeEventSubscriptions();
@ -82,7 +79,7 @@ export class UnifiedDataProvider implements DataProvider {
await this.eventBus.publish('market.data.response', {
requestId,
symbol,
error: error.message,
error: (error as Error).message,
status: 'error'
});
}
@ -111,7 +108,7 @@ export class UnifiedDataProvider implements DataProvider {
}
// Publish live data event
await this.eventBus.publishMarketData(symbol, liveData);
await this.eventBus.publish('marketData', liveData);
return liveData;
@ -304,7 +301,7 @@ export class UnifiedDataProvider implements DataProvider {
try {
const liveData = this.generateSimulatedData(symbol);
this.handleLiveData(liveData);
await this.eventBus.publishMarketData(symbol, liveData);
await this.eventBus.publish('marketData', liveData);
} catch (error) {
logger.error('Error in live data simulation', { symbol, error });
}
@ -353,7 +350,7 @@ export class UnifiedDataProvider implements DataProvider {
async close(): Promise<void> {
if (this.questdb) {
await this.questdb.close();
await this.questdb.disconnect();
}
this.cache.clear();
this.liveSubscriptions.clear();