Skip to content

Commit

Permalink
chore: update clients to be env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwaller committed Nov 21, 2024
1 parent d43d2d2 commit 4b9b337
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,14 @@ setGlobalDispatcher(

require('dotenv').config();

// Reading in Redis env vars
const REDIS_CLIENTS = [RedisClientPrefix.DLOB, RedisClientPrefix.DLOB_HELIUS];
const envClients = [];
const clients = process.env.REDIS_CLIENT.trim()
.replace(/^\[|\]$/g, '')
.split(/\s*,\s*/);

clients.forEach((client) => envClients.push(RedisClientPrefix[client]));

const REDIS_CLIENTS = envClients.length ? envClients : [RedisClientPrefix.DLOB, RedisClientPrefix.DLOB_HELIUS];
console.log('Redis Clients:', REDIS_CLIENTS);

const driftEnv = (process.env.ENV || 'devnet') as DriftEnv;
Expand Down
4 changes: 3 additions & 1 deletion src/publishers/tradesPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ setGlobalDispatcher(
require('dotenv').config();
const driftEnv = (process.env.ENV || 'devnet') as DriftEnv;
const commitHash = process.env.COMMIT;
const redisClientPrefix = RedisClientPrefix.DLOB_HELIUS;
const REDIS_CLIENT = process.env.REDIS_CLIENT || 'DLOB';
console.log('Redis Clients:', REDIS_CLIENT);
const redisClientPrefix = RedisClientPrefix[REDIS_CLIENT];
//@ts-ignore
const sdkConfig = initialize({ env: process.env.ENV });

Expand Down
9 changes: 8 additions & 1 deletion src/serverLite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ setGlobalDispatcher(
require('dotenv').config();

// Reading in Redis env vars
const REDIS_CLIENTS = [RedisClientPrefix.DLOB, RedisClientPrefix.DLOB_HELIUS];
const envClients = [];
const clients = process.env.REDIS_CLIENT.trim()
.replace(/^\[|\]$/g, '')
.split(/\s*,\s*/);

clients.forEach((client) => envClients.push(RedisClientPrefix[client]));

const REDIS_CLIENTS = envClients.length ? envClients : [RedisClientPrefix.DLOB, RedisClientPrefix.DLOB_HELIUS];
console.log('Redis Clients:', REDIS_CLIENTS);

const driftEnv = (process.env.ENV || 'devnet') as DriftEnv;
Expand Down
4 changes: 3 additions & 1 deletion src/wsConnectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ const WS_PORT = process.env.WS_PORT || '3000';
console.log(`WS LISTENER PORT : ${WS_PORT}`);

const MAX_BUFFERED_AMOUNT = 300000;
const CHANNEL_PREFIX = RedisClientPrefix.DLOB;
const REDIS_CLIENT = process.env.REDIS_CLIENT || 'DLOB';
const CHANNEL_PREFIX = RedisClientPrefix[REDIS_CLIENT];
console.log('Redis Clients:', REDIS_CLIENT);
const CHANNEL_PREFIX_HELIUS = RedisClientPrefix.DLOB_HELIUS;

const sanitiseChannelForClient = (channel: string | undefined): string => {
Expand Down

0 comments on commit 4b9b337

Please sign in to comment.