overleaf/services/document-updater/app/js/LockManager.js
Jakob Ackermann cd11db456d Merge pull request #7835 from overleaf/jpa-redis-locker-package
[misc] extract document-updaters LockManager into redis-wrapper package

GitOrigin-RevId: 5775ab9df7afb614dfc5f502df526c8735f84a91
2022-05-19 08:02:57 +00:00

17 lines
483 B
JavaScript

const Settings = require('@overleaf/settings')
const redis = require('@overleaf/redis-wrapper')
const rclient = redis.createClient(Settings.redis.lock)
const keys = Settings.redis.lock.key_schema
const RedisLocker = require('@overleaf/redis-wrapper/RedisLocker')
module.exports = new RedisLocker({
rclient,
getKey(docId) {
return keys.blockingKey({ doc_id: docId })
},
wrapTimeoutError(err, docId) {
err.doc_id = docId
return err
},
metricsPrefix: 'doc',
})