feat: sentinel configuration (#178)

* feat: sentinel configuration

* update

* redis update
This commit is contained in:
Hoan Luu Huu
2023-06-07 21:04:03 +07:00
committed by GitHub
parent 32ff023b14
commit f9df2b3028
2 changed files with 33 additions and 5 deletions
+24 -2
View File
@@ -1,5 +1,26 @@
const logger = require('../logger');
const JAMBONES_REDIS_SENTINELS = process.env.JAMBONES_REDIS_SENTINELS ? {
sentinels: process.env.JAMBONES_REDIS_SENTINELS.split(',').map((sentinel) => {
let host, port = 26379;
if (sentinel.includes(':')) {
const arr = sentinel.split(':');
host = arr[0];
port = parseInt(arr[1], 10);
} else {
host = sentinel;
}
return {host, port};
}),
name: process.env.JAMBONES_REDIS_SENTINEL_MASTER_NAME,
...(process.env.JAMBONES_REDIS_SENTINEL_PASSWORD && {
password: process.env.JAMBONES_REDIS_SENTINEL_PASSWORD
}),
...(process.env.JAMBONES_REDIS_SENTINEL_USERNAME && {
username: process.env.JAMBONES_REDIS_SENTINEL_USERNAME
})
} : null;
const {
retrieveCall,
deleteCall,
@@ -12,7 +33,7 @@ const {
deleteKey,
incrKey,
client: redisClient,
} = require('@jambonz/realtimedb-helpers')({
} = require('@jambonz/realtimedb-helpers')(JAMBONES_REDIS_SENTINELS || {
host: process.env.JAMBONES_REDIS_HOST || 'localhost',
port: process.env.JAMBONES_REDIS_PORT || 6379
}, logger);
@@ -28,5 +49,6 @@ module.exports = {
retrieveKey,
deleteKey,
redisClient,
incrKey
incrKey,
JAMBONES_REDIS_SENTINELS
};