mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 21:23:45 +01:00
* [document-updater] wrap doc locks in project lock * [document-updater] use BlockingProject as redis key prefix * [redis-wrapper] update comment GitOrigin-RevId: 0ce50e76386871e6c29481494febc8d6b37e7df5
22 lines
800 B
JavaScript
22 lines
800 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')
|
|
|
|
// Project level lock used to serialise processing of a project's pending
|
|
// updates (the `BlockingProject:{project_id}` key). Acquired before the per-doc
|
|
// `Blocking:{doc_id}` lock - never the other way around - to avoid deadlocks.
|
|
module.exports = new RedisLocker({
|
|
rclient,
|
|
getKey(projectId) {
|
|
return keys.projectBlockingKey({ project_id: projectId })
|
|
},
|
|
wrapTimeoutError(err, projectId) {
|
|
err.project_id = projectId
|
|
return err
|
|
},
|
|
metricsPrefix: 'project',
|
|
lockTTLSeconds: Settings.redisLockTTLSeconds,
|
|
})
|