updated loggers to getLogger
This commit is contained in:
parent
1ccdbddb71
commit
2aaeba2f6c
16 changed files with 72 additions and 97 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
import { ProxyInfo } from 'libs/http/src/types';
|
import { ProxyInfo } from 'libs/http/src/types';
|
||||||
import { ProviderConfig } from '../services/provider-registry.service';
|
import { ProviderConfig } from '../services/provider-registry.service';
|
||||||
import { Logger } from '@stock-bot/logger';
|
import { getLogger } from '@stock-bot/logger';
|
||||||
|
|
||||||
// Create logger for this provider
|
// Create logger for this provider
|
||||||
const logger = new Logger('proxy-provider');
|
const logger = getLogger('proxy-provider');
|
||||||
|
|
||||||
// This will run at the same time each day as when the app started
|
// This will run at the same time each day as when the app started
|
||||||
const getEvery24HourCron = (): string => {
|
const getEvery24HourCron = (): string => {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Logger } from '@stock-bot/logger';
|
import { getLogger } from '@stock-bot/logger';
|
||||||
import createCache, { type CacheProvider } from '@stock-bot/cache';
|
import createCache, { type CacheProvider } from '@stock-bot/cache';
|
||||||
import { HttpClient, ProxyInfo } from '@stock-bot/http';
|
import { HttpClient, ProxyInfo } from '@stock-bot/http';
|
||||||
import pLimit from 'p-limit';
|
import pLimit from 'p-limit';
|
||||||
|
|
@ -61,7 +61,7 @@ const PROXY_CONFIG = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Shared instances (module-scoped, not global)
|
// Shared instances (module-scoped, not global)
|
||||||
let logger: Logger;
|
let logger: ReturnType<typeof getLogger>;
|
||||||
let cache: CacheProvider;
|
let cache: CacheProvider;
|
||||||
let httpClient: HttpClient;
|
let httpClient: HttpClient;
|
||||||
let concurrencyLimit: ReturnType<typeof pLimit>;
|
let concurrencyLimit: ReturnType<typeof pLimit>;
|
||||||
|
|
@ -69,7 +69,7 @@ let concurrencyLimit: ReturnType<typeof pLimit>;
|
||||||
// Initialize shared resources
|
// Initialize shared resources
|
||||||
function initializeSharedResources() {
|
function initializeSharedResources() {
|
||||||
if (!logger) {
|
if (!logger) {
|
||||||
logger = new Logger('proxy-tasks');
|
logger = getLogger('proxy-tasks');
|
||||||
cache = createCache('hybrid');
|
cache = createCache('hybrid');
|
||||||
httpClient = new HttpClient({ timeout: 10000 }, logger);
|
httpClient = new HttpClient({ timeout: 10000 }, logger);
|
||||||
concurrencyLimit = pLimit(PROXY_CONFIG.CONCURRENCY_LIMIT);
|
concurrencyLimit = pLimit(PROXY_CONFIG.CONCURRENCY_LIMIT);
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
import { ProviderConfig } from '../services/provider-registry.service';
|
import { ProviderConfig } from '../services/provider-registry.service';
|
||||||
|
import { getLogger } from '@stock-bot/logger';
|
||||||
|
|
||||||
|
const logger = getLogger('quotemedia-provider');
|
||||||
|
|
||||||
export const quotemediaProvider: ProviderConfig = {
|
export const quotemediaProvider: ProviderConfig = {
|
||||||
name: 'quotemedia',
|
name: 'quotemedia',
|
||||||
service: 'market-data',
|
service: 'market-data',
|
||||||
operations: {
|
operations: { 'live-data': async (payload: { symbol: string; fields?: string[] }) => {
|
||||||
'live-data': async (payload: { symbol: string; fields?: string[] }) => {
|
|
||||||
const { Logger } = await import('@stock-bot/logger');
|
|
||||||
const logger = new Logger('quotemedia-provider');
|
|
||||||
|
|
||||||
logger.info('Fetching live data from QuoteMedia', { symbol: payload.symbol });
|
logger.info('Fetching live data from QuoteMedia', { symbol: payload.symbol });
|
||||||
|
|
||||||
// Simulate QuoteMedia API call
|
// Simulate QuoteMedia API call
|
||||||
|
|
@ -33,12 +32,8 @@ export const quotemediaProvider: ProviderConfig = {
|
||||||
from: Date;
|
from: Date;
|
||||||
to: Date;
|
to: Date;
|
||||||
interval?: string;
|
interval?: string;
|
||||||
fields?: string[];
|
fields?: string[]; }) => {
|
||||||
}) => {
|
logger.info('Fetching historical data from QuoteMedia', {
|
||||||
const { Logger } = await import('@stock-bot/logger');
|
|
||||||
const logger = new Logger('quotemedia-provider');
|
|
||||||
|
|
||||||
logger.info('Fetching historical data from QuoteMedia', {
|
|
||||||
symbol: payload.symbol,
|
symbol: payload.symbol,
|
||||||
from: payload.from,
|
from: payload.from,
|
||||||
to: payload.to,
|
to: payload.to,
|
||||||
|
|
@ -73,12 +68,8 @@ export const quotemediaProvider: ProviderConfig = {
|
||||||
totalRecords: data.length
|
totalRecords: data.length
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
'batch-quotes': async (payload: { symbols: string[]; fields?: string[] }) => {
|
||||||
'batch-quotes': async (payload: { symbols: string[]; fields?: string[] }) => {
|
logger.info('Fetching batch quotes from QuoteMedia', {
|
||||||
const { Logger } = await import('@stock-bot/logger');
|
|
||||||
const logger = new Logger('quotemedia-provider');
|
|
||||||
|
|
||||||
logger.info('Fetching batch quotes from QuoteMedia', {
|
|
||||||
symbols: payload.symbols,
|
symbols: payload.symbols,
|
||||||
count: payload.symbols.length
|
count: payload.symbols.length
|
||||||
});
|
});
|
||||||
|
|
@ -101,12 +92,7 @@ export const quotemediaProvider: ProviderConfig = {
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
totalSymbols: payload.symbols.length
|
totalSymbols: payload.symbols.length
|
||||||
};
|
};
|
||||||
},
|
}, 'company-profile': async (payload: { symbol: string }) => {
|
||||||
|
|
||||||
'company-profile': async (payload: { symbol: string }) => {
|
|
||||||
const { Logger } = await import('@stock-bot/logger');
|
|
||||||
const logger = new Logger('quotemedia-provider');
|
|
||||||
|
|
||||||
logger.info('Fetching company profile from QuoteMedia', { symbol: payload.symbol });
|
logger.info('Fetching company profile from QuoteMedia', { symbol: payload.symbol });
|
||||||
|
|
||||||
// Simulate company profile data
|
// Simulate company profile data
|
||||||
|
|
@ -125,13 +111,8 @@ export const quotemediaProvider: ProviderConfig = {
|
||||||
await new Promise(resolve => setTimeout(resolve, 150 + Math.random() * 100));
|
await new Promise(resolve => setTimeout(resolve, 150 + Math.random() * 100));
|
||||||
|
|
||||||
return profile;
|
return profile;
|
||||||
},
|
}, 'options-chain': async (payload: { symbol: string; expiration?: string }) => {
|
||||||
|
logger.info('Fetching options chain from QuoteMedia', {
|
||||||
'options-chain': async (payload: { symbol: string; expiration?: string }) => {
|
|
||||||
const { Logger } = await import('@stock-bot/logger');
|
|
||||||
const logger = new Logger('quotemedia-provider');
|
|
||||||
|
|
||||||
logger.info('Fetching options chain from QuoteMedia', {
|
|
||||||
symbol: payload.symbol,
|
symbol: payload.symbol,
|
||||||
expiration: payload.expiration
|
expiration: payload.expiration
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
import { ProviderConfig } from '../services/provider-registry.service';
|
import { ProviderConfig } from '../services/provider-registry.service';
|
||||||
|
import { getLogger } from '@stock-bot/logger';
|
||||||
|
|
||||||
|
const logger = getLogger('yahoo-provider');
|
||||||
|
|
||||||
export const yahooProvider: ProviderConfig = {
|
export const yahooProvider: ProviderConfig = {
|
||||||
name: 'yahoo-finance',
|
name: 'yahoo-finance',
|
||||||
service: 'market-data',
|
service: 'market-data',
|
||||||
operations: {
|
operations: {
|
||||||
'live-data': async (payload: { symbol: string; modules?: string[] }) => {
|
'live-data': async (payload: { symbol: string; modules?: string[] }) => {
|
||||||
const { Logger } = await import('@stock-bot/logger');
|
|
||||||
const logger = new Logger('yahoo-provider');
|
|
||||||
|
|
||||||
logger.info('Fetching live data from Yahoo Finance', { symbol: payload.symbol });
|
logger.info('Fetching live data from Yahoo Finance', { symbol: payload.symbol });
|
||||||
|
|
||||||
|
|
@ -40,12 +42,11 @@ export const yahooProvider: ProviderConfig = {
|
||||||
period1: number;
|
period1: number;
|
||||||
period2: number;
|
period2: number;
|
||||||
interval?: string;
|
interval?: string;
|
||||||
events?: string;
|
events?: string; }) => {
|
||||||
}) => {
|
const { getLogger } = await import('@stock-bot/logger');
|
||||||
const { Logger } = await import('@stock-bot/logger');
|
const logger = getLogger('yahoo-provider');
|
||||||
const logger = new Logger('yahoo-provider');
|
|
||||||
|
|
||||||
logger.info('Fetching historical data from Yahoo Finance', {
|
logger.info('Fetching historical data from Yahoo Finance', {
|
||||||
symbol: payload.symbol,
|
symbol: payload.symbol,
|
||||||
period1: payload.period1,
|
period1: payload.period1,
|
||||||
period2: payload.period2,
|
period2: payload.period2,
|
||||||
|
|
@ -94,10 +95,9 @@ export const yahooProvider: ProviderConfig = {
|
||||||
totalRecords: data.length
|
totalRecords: data.length
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
'search': async (payload: { query: string; quotesCount?: number; newsCount?: number }) => {
|
||||||
'search': async (payload: { query: string; quotesCount?: number; newsCount?: number }) => {
|
const { getLogger } = await import('@stock-bot/logger');
|
||||||
const { Logger } = await import('@stock-bot/logger');
|
const logger = getLogger('yahoo-provider');
|
||||||
const logger = new Logger('yahoo-provider');
|
|
||||||
|
|
||||||
logger.info('Searching Yahoo Finance', { query: payload.query });
|
logger.info('Searching Yahoo Finance', { query: payload.query });
|
||||||
|
|
||||||
|
|
@ -129,13 +129,11 @@ export const yahooProvider: ProviderConfig = {
|
||||||
totalNews: news.length,
|
totalNews: news.length,
|
||||||
source: 'yahoo-finance'
|
source: 'yahoo-finance'
|
||||||
};
|
};
|
||||||
},
|
}, 'financials': async (payload: { symbol: string; type?: 'income' | 'balance' | 'cash' }) => {
|
||||||
|
const { getLogger } = await import('@stock-bot/logger');
|
||||||
'financials': async (payload: { symbol: string; type?: 'income' | 'balance' | 'cash' }) => {
|
const logger = getLogger('yahoo-provider');
|
||||||
const { Logger } = await import('@stock-bot/logger');
|
|
||||||
const logger = new Logger('yahoo-provider');
|
|
||||||
|
|
||||||
logger.info('Fetching financials from Yahoo Finance', {
|
logger.info('Fetching financials from Yahoo Finance', {
|
||||||
symbol: payload.symbol,
|
symbol: payload.symbol,
|
||||||
type: payload.type || 'income'
|
type: payload.type || 'income'
|
||||||
});
|
});
|
||||||
|
|
@ -163,13 +161,11 @@ export const yahooProvider: ProviderConfig = {
|
||||||
await new Promise(resolve => setTimeout(resolve, 300 + Math.random() * 200));
|
await new Promise(resolve => setTimeout(resolve, 300 + Math.random() * 200));
|
||||||
|
|
||||||
return financials;
|
return financials;
|
||||||
},
|
}, 'earnings': async (payload: { symbol: string; period?: 'annual' | 'quarterly' }) => {
|
||||||
|
const { getLogger } = await import('@stock-bot/logger');
|
||||||
'earnings': async (payload: { symbol: string; period?: 'annual' | 'quarterly' }) => {
|
const logger = getLogger('yahoo-provider');
|
||||||
const { Logger } = await import('@stock-bot/logger');
|
|
||||||
const logger = new Logger('yahoo-provider');
|
|
||||||
|
|
||||||
logger.info('Fetching earnings from Yahoo Finance', {
|
logger.info('Fetching earnings from Yahoo Finance', {
|
||||||
symbol: payload.symbol,
|
symbol: payload.symbol,
|
||||||
period: payload.period || 'quarterly'
|
period: payload.period || 'quarterly'
|
||||||
});
|
});
|
||||||
|
|
@ -192,11 +188,9 @@ export const yahooProvider: ProviderConfig = {
|
||||||
await new Promise(resolve => setTimeout(resolve, 250 + Math.random() * 150));
|
await new Promise(resolve => setTimeout(resolve, 250 + Math.random() * 150));
|
||||||
|
|
||||||
return earnings;
|
return earnings;
|
||||||
},
|
}, 'recommendations': async (payload: { symbol: string }) => {
|
||||||
|
const { getLogger } = await import('@stock-bot/logger');
|
||||||
'recommendations': async (payload: { symbol: string }) => {
|
const logger = getLogger('yahoo-provider');
|
||||||
const { Logger } = await import('@stock-bot/logger');
|
|
||||||
const logger = new Logger('yahoo-provider');
|
|
||||||
|
|
||||||
logger.info('Fetching recommendations from Yahoo Finance', { symbol: payload.symbol });
|
logger.info('Fetching recommendations from Yahoo Finance', { symbol: payload.symbol });
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Logger } from '@stock-bot/logger';
|
import { getLogger } from '@stock-bot/logger';
|
||||||
|
|
||||||
export interface JobHandler {
|
export interface JobHandler {
|
||||||
(payload: any): Promise<any>;
|
(payload: any): Promise<any>;
|
||||||
|
|
@ -22,7 +22,7 @@ export interface ProviderConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ProviderRegistry {
|
export class ProviderRegistry {
|
||||||
private logger = new Logger('provider-registry');
|
private logger = getLogger('provider-registry');
|
||||||
private providers = new Map<string, ProviderConfig>();
|
private providers = new Map<string, ProviderConfig>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { Queue, Worker, QueueEvents } from 'bullmq';
|
import { Queue, Worker, QueueEvents } from 'bullmq';
|
||||||
import { Logger } from '@stock-bot/logger';
|
import { getLogger } from '@stock-bot/logger';
|
||||||
import { providerRegistry } from './provider-registry.service';
|
import { providerRegistry } from './provider-registry.service';
|
||||||
|
|
||||||
export interface JobData {
|
export interface JobData {
|
||||||
|
|
@ -13,7 +13,7 @@ export interface JobData {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class QueueService {
|
export class QueueService {
|
||||||
private logger = new Logger('queue-service');
|
private logger = getLogger('queue-service');
|
||||||
private queue!: Queue;
|
private queue!: Queue;
|
||||||
private workers: Worker[] = [];
|
private workers: Worker[] = [];
|
||||||
private queueEvents!: QueueEvents;
|
private queueEvents!: QueueEvents;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { MongoClient, Db, Collection, MongoClientOptions, Document, WithId, OptionalUnlessRequiredId } from 'mongodb';
|
import { MongoClient, Db, Collection, MongoClientOptions, Document, WithId, OptionalUnlessRequiredId } from 'mongodb';
|
||||||
import { mongodbConfig } from '@stock-bot/config';
|
import { mongodbConfig } from '@stock-bot/config';
|
||||||
import { Logger } from '@stock-bot/logger';
|
import { getLogger } from '@stock-bot/logger';
|
||||||
import type {
|
import type {
|
||||||
MongoDBClientConfig,
|
MongoDBClientConfig,
|
||||||
MongoDBConnectionOptions,
|
MongoDBConnectionOptions,
|
||||||
|
|
@ -28,7 +28,7 @@ export class MongoDBClient {
|
||||||
private db: Db | null = null;
|
private db: Db | null = null;
|
||||||
private readonly config: MongoDBClientConfig;
|
private readonly config: MongoDBClientConfig;
|
||||||
private readonly options: MongoDBConnectionOptions;
|
private readonly options: MongoDBConnectionOptions;
|
||||||
private readonly logger: Logger;
|
private readonly logger: ReturnType<typeof getLogger>;
|
||||||
private readonly healthMonitor: MongoDBHealthMonitor;
|
private readonly healthMonitor: MongoDBHealthMonitor;
|
||||||
private isConnected = false;
|
private isConnected = false;
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ export class MongoDBClient {
|
||||||
...options
|
...options
|
||||||
};
|
};
|
||||||
|
|
||||||
this.logger = new Logger('MongoDBClient');
|
this.logger = getLogger('mongodb-client');
|
||||||
this.healthMonitor = new MongoDBHealthMonitor(this);
|
this.healthMonitor = new MongoDBHealthMonitor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Logger } from '@stock-bot/logger';
|
import { getLogger } from '@stock-bot/logger';
|
||||||
import type { MongoDBClient } from './client';
|
import type { MongoDBClient } from './client';
|
||||||
import type { MongoDBHealthCheck, MongoDBHealthStatus, MongoDBMetrics } from './types';
|
import type { MongoDBHealthCheck, MongoDBHealthStatus, MongoDBMetrics } from './types';
|
||||||
|
|
||||||
|
|
@ -9,14 +9,14 @@ import type { MongoDBHealthCheck, MongoDBHealthStatus, MongoDBMetrics } from './
|
||||||
*/
|
*/
|
||||||
export class MongoDBHealthMonitor {
|
export class MongoDBHealthMonitor {
|
||||||
private readonly client: MongoDBClient;
|
private readonly client: MongoDBClient;
|
||||||
private readonly logger: Logger;
|
private readonly logger: ReturnType<typeof getLogger>;
|
||||||
private healthCheckInterval: NodeJS.Timeout | null = null;
|
private healthCheckInterval: NodeJS.Timeout | null = null;
|
||||||
private metrics: MongoDBMetrics;
|
private metrics: MongoDBMetrics;
|
||||||
private lastHealthCheck: MongoDBHealthCheck | null = null;
|
private lastHealthCheck: MongoDBHealthCheck | null = null;
|
||||||
|
|
||||||
constructor(client: MongoDBClient) {
|
constructor(client: MongoDBClient) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.logger = new Logger('MongoDBHealthMonitor');
|
this.logger = getLogger('mongodb-health-monitor');
|
||||||
this.metrics = {
|
this.metrics = {
|
||||||
operationsPerSecond: 0,
|
operationsPerSecond: 0,
|
||||||
averageLatency: 0,
|
averageLatency: 0,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Logger } from '@stock-bot/logger';
|
import { getLogger } from '@stock-bot/logger';
|
||||||
import type { MongoDBClient } from './client';
|
import type { MongoDBClient } from './client';
|
||||||
import type { CollectionNames, DocumentBase } from './types';
|
import type { CollectionNames, DocumentBase } from './types';
|
||||||
import type { WithId, OptionalUnlessRequiredId } from 'mongodb';
|
import type { WithId, OptionalUnlessRequiredId } from 'mongodb';
|
||||||
|
|
@ -10,11 +10,11 @@ import type { WithId, OptionalUnlessRequiredId } from 'mongodb';
|
||||||
*/
|
*/
|
||||||
export class MongoDBTransactionManager {
|
export class MongoDBTransactionManager {
|
||||||
private readonly client: MongoDBClient;
|
private readonly client: MongoDBClient;
|
||||||
private readonly logger: Logger;
|
private readonly logger: ReturnType<typeof getLogger>;
|
||||||
|
|
||||||
constructor(client: MongoDBClient) {
|
constructor(client: MongoDBClient) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.logger = new Logger('MongoDBTransactionManager');
|
this.logger = getLogger('mongodb-transaction-manager');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { Pool, PoolClient, QueryResult as PgQueryResult, QueryResultRow } from 'pg';
|
import { Pool, PoolClient, QueryResult as PgQueryResult, QueryResultRow } from 'pg';
|
||||||
import { postgresConfig } from '@stock-bot/config';
|
import { postgresConfig } from '@stock-bot/config';
|
||||||
import { Logger } from '@stock-bot/logger';
|
import { getLogger } from '@stock-bot/logger';
|
||||||
import type {
|
import type {
|
||||||
PostgreSQLClientConfig,
|
PostgreSQLClientConfig,
|
||||||
PostgreSQLConnectionOptions,
|
PostgreSQLConnectionOptions,
|
||||||
|
|
@ -21,7 +21,7 @@ export class PostgreSQLClient {
|
||||||
private pool: Pool | null = null;
|
private pool: Pool | null = null;
|
||||||
private readonly config: PostgreSQLClientConfig;
|
private readonly config: PostgreSQLClientConfig;
|
||||||
private readonly options: PostgreSQLConnectionOptions;
|
private readonly options: PostgreSQLConnectionOptions;
|
||||||
private readonly logger: Logger;
|
private readonly logger: ReturnType<typeof getLogger>;
|
||||||
private readonly healthMonitor: PostgreSQLHealthMonitor;
|
private readonly healthMonitor: PostgreSQLHealthMonitor;
|
||||||
private readonly transactionManager: PostgreSQLTransactionManager;
|
private readonly transactionManager: PostgreSQLTransactionManager;
|
||||||
private isConnected = false;
|
private isConnected = false;
|
||||||
|
|
@ -38,7 +38,7 @@ export class PostgreSQLClient {
|
||||||
...options
|
...options
|
||||||
};
|
};
|
||||||
|
|
||||||
this.logger = new Logger('PostgreSQLClient');
|
this.logger = getLogger('postgres-client');
|
||||||
this.healthMonitor = new PostgreSQLHealthMonitor(this);
|
this.healthMonitor = new PostgreSQLHealthMonitor(this);
|
||||||
this.transactionManager = new PostgreSQLTransactionManager(this);
|
this.transactionManager = new PostgreSQLTransactionManager(this);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Logger } from '@stock-bot/logger';
|
import { getLogger } from '@stock-bot/logger';
|
||||||
import type { PostgreSQLClient } from './client';
|
import type { PostgreSQLClient } from './client';
|
||||||
import type { PostgreSQLHealthCheck, PostgreSQLHealthStatus, PostgreSQLMetrics } from './types';
|
import type { PostgreSQLHealthCheck, PostgreSQLHealthStatus, PostgreSQLMetrics } from './types';
|
||||||
|
|
||||||
|
|
@ -9,14 +9,14 @@ import type { PostgreSQLHealthCheck, PostgreSQLHealthStatus, PostgreSQLMetrics }
|
||||||
*/
|
*/
|
||||||
export class PostgreSQLHealthMonitor {
|
export class PostgreSQLHealthMonitor {
|
||||||
private readonly client: PostgreSQLClient;
|
private readonly client: PostgreSQLClient;
|
||||||
private readonly logger: Logger;
|
private readonly logger: ReturnType<typeof getLogger>;
|
||||||
private healthCheckInterval: NodeJS.Timeout | null = null;
|
private healthCheckInterval: NodeJS.Timeout | null = null;
|
||||||
private metrics: PostgreSQLMetrics;
|
private metrics: PostgreSQLMetrics;
|
||||||
private lastHealthCheck: PostgreSQLHealthCheck | null = null;
|
private lastHealthCheck: PostgreSQLHealthCheck | null = null;
|
||||||
|
|
||||||
constructor(client: PostgreSQLClient) {
|
constructor(client: PostgreSQLClient) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.logger = new Logger('PostgreSQLHealthMonitor');
|
this.logger = getLogger('postgres-health-monitor');
|
||||||
this.metrics = {
|
this.metrics = {
|
||||||
queriesPerSecond: 0,
|
queriesPerSecond: 0,
|
||||||
averageQueryTime: 0,
|
averageQueryTime: 0,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { PoolClient } from 'pg';
|
import { PoolClient } from 'pg';
|
||||||
import { Logger } from '@stock-bot/logger';
|
import { getLogger } from '@stock-bot/logger';
|
||||||
import type { PostgreSQLClient } from './client';
|
import type { PostgreSQLClient } from './client';
|
||||||
import type { TransactionCallback } from './types';
|
import type { TransactionCallback } from './types';
|
||||||
|
|
||||||
|
|
@ -10,11 +10,11 @@ import type { TransactionCallback } from './types';
|
||||||
*/
|
*/
|
||||||
export class PostgreSQLTransactionManager {
|
export class PostgreSQLTransactionManager {
|
||||||
private readonly client: PostgreSQLClient;
|
private readonly client: PostgreSQLClient;
|
||||||
private readonly logger: Logger;
|
private readonly logger: ReturnType<typeof getLogger>;
|
||||||
|
|
||||||
constructor(client: PostgreSQLClient) {
|
constructor(client: PostgreSQLClient) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.logger = new Logger('PostgreSQLTransactionManager');
|
this.logger = getLogger('postgres-transaction-manager');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Logger } from '@stock-bot/logger';
|
import { getLogger } from '@stock-bot/logger';
|
||||||
import type { HealthStatus, PerformanceMetrics, QueryResult } from './types';
|
import type { HealthStatus, PerformanceMetrics, QueryResult } from './types';
|
||||||
|
|
||||||
// Interface to avoid circular dependency
|
// Interface to avoid circular dependency
|
||||||
|
|
@ -14,7 +14,7 @@ interface QuestDBClientInterface {
|
||||||
* automatic recovery capabilities for the QuestDB client.
|
* automatic recovery capabilities for the QuestDB client.
|
||||||
*/
|
*/
|
||||||
export class QuestDBHealthMonitor {
|
export class QuestDBHealthMonitor {
|
||||||
private readonly logger: Logger;
|
private readonly logger: ReturnType<typeof getLogger>;
|
||||||
private healthCheckInterval: NodeJS.Timeout | null = null;
|
private healthCheckInterval: NodeJS.Timeout | null = null;
|
||||||
private lastHealthCheck: Date | null = null;
|
private lastHealthCheck: Date | null = null;
|
||||||
private performanceMetrics: PerformanceMetrics = {
|
private performanceMetrics: PerformanceMetrics = {
|
||||||
|
|
@ -27,7 +27,7 @@ export class QuestDBHealthMonitor {
|
||||||
memoryUsage: 0
|
memoryUsage: 0
|
||||||
};
|
};
|
||||||
constructor(private readonly client: QuestDBClientInterface) {
|
constructor(private readonly client: QuestDBClientInterface) {
|
||||||
this.logger = new Logger('QuestDBHealthMonitor');
|
this.logger = getLogger('questdb-health-monitor');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Logger } from '@stock-bot/logger';
|
import { getLogger } from '@stock-bot/logger';
|
||||||
import type {
|
import type {
|
||||||
InfluxLineData,
|
InfluxLineData,
|
||||||
InfluxWriteOptions,
|
InfluxWriteOptions,
|
||||||
|
|
@ -17,7 +17,7 @@ interface QuestDBClientInterface {
|
||||||
* which QuestDB supports natively for optimal time-series data insertion.
|
* which QuestDB supports natively for optimal time-series data insertion.
|
||||||
*/
|
*/
|
||||||
export class QuestDBInfluxWriter {
|
export class QuestDBInfluxWriter {
|
||||||
private readonly logger: Logger;
|
private readonly logger: ReturnType<typeof getLogger>;
|
||||||
private writeBuffer: string[] = [];
|
private writeBuffer: string[] = [];
|
||||||
private flushTimer: NodeJS.Timeout | null = null;
|
private flushTimer: NodeJS.Timeout | null = null;
|
||||||
private readonly defaultOptions: Required<InfluxWriteOptions> = {
|
private readonly defaultOptions: Required<InfluxWriteOptions> = {
|
||||||
|
|
@ -29,7 +29,7 @@ export class QuestDBInfluxWriter {
|
||||||
retryDelay: 1000
|
retryDelay: 1000
|
||||||
};
|
};
|
||||||
constructor(private readonly client: QuestDBClientInterface) {
|
constructor(private readonly client: QuestDBClientInterface) {
|
||||||
this.logger = new Logger('QuestDBInfluxWriter');
|
this.logger = getLogger('questdb-influx-writer');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Logger } from '@stock-bot/logger';
|
import { getLogger } from '@stock-bot/logger';
|
||||||
import type {
|
import type {
|
||||||
QueryResult,
|
QueryResult,
|
||||||
TimeSeriesQuery,
|
TimeSeriesQuery,
|
||||||
|
|
@ -19,7 +19,7 @@ interface QuestDBClientInterface {
|
||||||
* with support for QuestDB-specific functions and optimizations.
|
* with support for QuestDB-specific functions and optimizations.
|
||||||
*/
|
*/
|
||||||
export class QuestDBQueryBuilder {
|
export class QuestDBQueryBuilder {
|
||||||
private readonly logger: Logger;
|
private readonly logger: ReturnType<typeof getLogger>;
|
||||||
private query!: {
|
private query!: {
|
||||||
select: string[];
|
select: string[];
|
||||||
from: string;
|
from: string;
|
||||||
|
|
@ -32,7 +32,7 @@ export class QuestDBQueryBuilder {
|
||||||
timeRange?: TimeRange;
|
timeRange?: TimeRange;
|
||||||
};
|
};
|
||||||
constructor(private readonly client: QuestDBClientInterface) {
|
constructor(private readonly client: QuestDBClientInterface) {
|
||||||
this.logger = new Logger('QuestDBQueryBuilder');
|
this.logger = getLogger('questdb-query-builder');
|
||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Logger } from '@stock-bot/logger';
|
import { getLogger } from '@stock-bot/logger';
|
||||||
import type { TableSchema, IndexDefinition, TableNames, QueryResult } from './types';
|
import type { TableSchema, IndexDefinition, TableNames, QueryResult } from './types';
|
||||||
|
|
||||||
// Interface to avoid circular dependency
|
// Interface to avoid circular dependency
|
||||||
|
|
@ -13,10 +13,10 @@ interface QuestDBClientInterface {
|
||||||
* for time-series data storage in QuestDB.
|
* for time-series data storage in QuestDB.
|
||||||
*/
|
*/
|
||||||
export class QuestDBSchemaManager {
|
export class QuestDBSchemaManager {
|
||||||
private readonly logger: Logger;
|
private readonly logger: ReturnType<typeof getLogger>;
|
||||||
private readonly schemas: Map<string, TableSchema> = new Map();
|
private readonly schemas: Map<string, TableSchema> = new Map();
|
||||||
constructor(private readonly client: QuestDBClientInterface) {
|
constructor(private readonly client: QuestDBClientInterface) {
|
||||||
this.logger = new Logger('QuestDBSchemaManager');
|
this.logger = getLogger('questdb-schema-manager');
|
||||||
this.initializeSchemas();
|
this.initializeSchemas();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue