refactored db's and browser
This commit is contained in:
parent
a0a3b26177
commit
89cbfb7848
12 changed files with 111 additions and 39 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import { Pool } from 'pg';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import { QuestDBHealthMonitor } from './health';
|
||||
import { QuestDBInfluxWriter } from './influx-writer';
|
||||
import { QuestDBQueryBuilder } from './query-builder';
|
||||
|
|
@ -21,14 +20,15 @@ export class QuestDBClient {
|
|||
private pgPool: Pool | null = null;
|
||||
private readonly config: QuestDBClientConfig;
|
||||
private readonly options: QuestDBConnectionOptions;
|
||||
private readonly logger = getLogger('QuestDBClient');
|
||||
private readonly logger: any;
|
||||
private readonly healthMonitor: QuestDBHealthMonitor;
|
||||
private readonly influxWriter: QuestDBInfluxWriter;
|
||||
private readonly schemaManager: QuestDBSchemaManager;
|
||||
private isConnected = false;
|
||||
|
||||
constructor(config: QuestDBClientConfig, options?: QuestDBConnectionOptions) {
|
||||
constructor(config: QuestDBClientConfig, logger?: any, options?: QuestDBConnectionOptions) {
|
||||
this.config = config;
|
||||
this.logger = logger || console;
|
||||
this.options = {
|
||||
protocol: 'pg',
|
||||
retryAttempts: 3,
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@ import type { QuestDBClientConfig, QuestDBConnectionOptions } from './types';
|
|||
*/
|
||||
export function createQuestDBClient(
|
||||
config: QuestDBClientConfig,
|
||||
logger?: any,
|
||||
options?: QuestDBConnectionOptions
|
||||
): QuestDBClient {
|
||||
return new QuestDBClient(config, options);
|
||||
return new QuestDBClient(config, logger, options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -16,9 +17,10 @@ export function createQuestDBClient(
|
|||
*/
|
||||
export async function createAndConnectQuestDBClient(
|
||||
config: QuestDBClientConfig,
|
||||
logger?: any,
|
||||
options?: QuestDBConnectionOptions
|
||||
): Promise<QuestDBClient> {
|
||||
const client = createQuestDBClient(config, options);
|
||||
const client = createQuestDBClient(config, logger, options);
|
||||
await client.connect();
|
||||
return client;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue