Merge pull request #24749 from overleaf/bg-history-redis-buffer

add history redis to history-v1

GitOrigin-RevId: 70dc1aee809ad17902c93c020f3804c0f1429238
This commit is contained in:
Brian Gough
2025-04-09 13:51:55 +01:00
committed by Copybot
parent d85dbe429d
commit 4ba0e97b95
2 changed files with 29 additions and 2 deletions

View File

@@ -89,6 +89,16 @@
"host": "QUEUES_REDIS_HOST",
"password": "QUEUES_REDIS_PASSWORD",
"port": "QUEUES_REDIS_PORT"
},
"history": {
"host": "HISTORY_REDIS_HOST",
"password": "HISTORY_REDIS_PASSWORD",
"port": "HISTORY_REDIS_PORT"
},
"lock": {
"host": "REDIS_HOST",
"password": "REDIS_PASSWORD",
"port": "REDIS_PORT"
}
}
}

View File

@@ -1,11 +1,28 @@
import redis from '@overleaf/redis-wrapper'
import config from 'config'
const redisOptions = config.get('redis.queue')
// Get allowed Redis dbs from config
const redisConfig = config.get('redis')
const allowedDbs = Object.keys(redisConfig)
// Get the Redis db from command line argument or use the first available db as default
const db = process.argv[2]
// Validate redis db
if (!allowedDbs.includes(db)) {
if (db) {
console.error('Invalid redis db:', db)
}
console.error(`Usage: node redis.mjs [${allowedDbs.join('|')}]`)
process.exit(1)
}
// Get redis options based on command line argument
const redisOptions = config.get(`redis.${db}`)
console.log('Using redis db:', db)
console.log('REDIS CONFIG', {
...redisOptions,
password: '*'.repeat(redisOptions.password.length),
password: '*'.repeat(redisOptions.password?.length),
})
const rclient = redis.createClient(redisOptions)