Skip to content
Snippets Groups Projects
Commit a05aa099 authored by Leonardo's avatar Leonardo
Browse files

chore: make redis connector a global var

making it inline with other services
parent e1db8b2b
No related branches found
No related tags found
No related merge requests found
Pipeline #144774 failed
import { RedisConnector } from 'ts-common/redis';
import { RabbitMqBroker } from 'ts-common/rabbitMq';
import { REDIS_PASSWORD, REDIS_HOST, REDIS_PORT, RABBIT_USER, RABBIT_PASSWORD, RABBIT_PORT, RABBIT_HOST, rabbitMq } from './variables';
import { rabbitMq, redis } from './variables';
import { log } from './logger';
import { queryServiceReader } from './readers/queryService';
import { insightProcessor } from './readers/insightProcessor';
......@@ -21,11 +20,10 @@ async function main() {
log.info('Connected to RabbitMQ!');
log.info('Connecting to Redis...');
const redis = new RedisConnector(REDIS_PASSWORD, REDIS_HOST, REDIS_PORT);
await redis.connect();
log.info('Connected to Redis!');
queryServiceReader(frontendPublisher, mlPublisher, redis, 'neo4j');
queryServiceReader(frontendPublisher, mlPublisher, 'neo4j');
insightProcessor();
// TODO: other query services for other databases
......
import { type DbConnection, type QueryRequest } from 'ts-common';
import { rabbitMq, ums, type QueryExecutionTypes } from '../variables';
import { rabbitMq, redis, ums, type QueryExecutionTypes } from '../variables';
import { log } from '../logger';
import { QueryPublisher } from '../utils/queryPublisher';
import { query2Cypher } from '../utils/cypher/converter';
......@@ -32,12 +32,7 @@ export const queryService = async (db: DbConnection, query: string): Promise<Gra
}
};
export const queryServiceReader = async (
frontendPublisher: RabbitMqBroker,
mlPublisher: RabbitMqBroker,
redis: RedisConnector,
type: QueryExecutionTypes,
) => {
export const queryServiceReader = async (frontendPublisher: RabbitMqBroker, mlPublisher: RabbitMqBroker, type: QueryExecutionTypes) => {
if (type == null) {
log.error('Unsupported query execution type:', type);
throw new Error('Unsupported query execution type');
......
import { UMSApi } from 'ts-common';
import { RabbitMqConnection } from 'ts-common/rabbitMq';
import nodemailer from 'nodemailer';
import { RedisConnector } from 'ts-common/redis';
export type QueryExecutionTypes = 'neo4j';
......@@ -20,6 +21,8 @@ export const REDIS_PORT = parseInt(Bun.env.REDIS_PORT || '6379');
export const REDIS_PASSWORD = Bun.env.REDIS_PASSWORD || 'DevOnlyPass';
export const REDIS_SCHEMA_CACHE_DURATION = Bun.env.REDIS_SCHEMA_CACHE_DURATION || '60m';
export const redis = new RedisConnector(REDIS_PASSWORD, REDIS_HOST, REDIS_PORT);
export const ums = new UMSApi(USER_MANAGEMENT_SERVICE_API);
export const rabbitMq = new RabbitMqConnection({
protocol: 'amqp',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment