2021-07-12 12:47:15 -04:00
|
|
|
const Settings = require('@overleaf/settings')
|
2020-11-10 06:32:04 -05:00
|
|
|
const redis = require('@overleaf/redis-wrapper')
|
2020-05-06 06:09:33 -04:00
|
|
|
const rclient = redis.createClient(Settings.redis.lock)
|
|
|
|
const keys = Settings.redis.lock.key_schema
|
2022-05-18 04:22:20 -04:00
|
|
|
const RedisLocker = require('@overleaf/redis-wrapper/RedisLocker')
|
2016-04-13 06:59:56 -04:00
|
|
|
|
2022-05-18 04:22:20 -04:00
|
|
|
module.exports = new RedisLocker({
|
|
|
|
rclient,
|
|
|
|
getKey(docId) {
|
|
|
|
return keys.blockingKey({ doc_id: docId })
|
2020-05-06 06:09:33 -04:00
|
|
|
},
|
2022-05-18 04:22:20 -04:00
|
|
|
wrapTimeoutError(err, docId) {
|
|
|
|
err.doc_id = docId
|
|
|
|
return err
|
2021-07-13 07:04:42 -04:00
|
|
|
},
|
2022-05-18 04:22:20 -04:00
|
|
|
metricsPrefix: 'doc',
|
2024-01-19 03:33:27 -05:00
|
|
|
lockTTLSeconds: Settings.redisLockTTLSeconds,
|
2022-05-18 04:22:20 -04:00
|
|
|
})
|