|
@@ -65,10 +65,10 @@ async function commitChanges(
|
|
|
await queueChanges(projectId, changes, endVersion)
|
|
await queueChanges(projectId, changes, endVersion)
|
|
|
return await persistBuffer(projectId, limits)
|
|
return await persistBuffer(projectId, limits)
|
|
|
case 2: // Equivalent to queueChangesInRedis:true
|
|
case 2: // Equivalent to queueChangesInRedis:true
|
|
|
- await queueChangesFake(projectId, changes, limits, endVersion)
|
|
|
|
|
|
|
+ await queueChangesFake(projectId, changes, endVersion)
|
|
|
return await persistChanges(projectId, changes, limits, endVersion)
|
|
return await persistChanges(projectId, changes, limits, endVersion)
|
|
|
case 1: // Queue changes with fake persist only for projects in redis already
|
|
case 1: // Queue changes with fake persist only for projects in redis already
|
|
|
- await queueChangesFakeOnlyIfExists(projectId, changes, limits, endVersion)
|
|
|
|
|
|
|
+ await queueChangesFakeOnlyIfExists(projectId, changes, endVersion)
|
|
|
return await persistChanges(projectId, changes, limits, endVersion)
|
|
return await persistChanges(projectId, changes, limits, endVersion)
|
|
|
case 0: // Persist changes directly to the chunk store
|
|
case 0: // Persist changes directly to the chunk store
|
|
|
return await persistChanges(projectId, changes, limits, endVersion)
|
|
return await persistChanges(projectId, changes, limits, endVersion)
|
|
@@ -81,20 +81,13 @@ async function commitChanges(
|
|
|
* Queues a set of changes in redis as if they had been persisted, ignoring any errors.
|
|
* Queues a set of changes in redis as if they had been persisted, ignoring any errors.
|
|
|
* @param {string} projectId
|
|
* @param {string} projectId
|
|
|
* @param {Change[]} changes
|
|
* @param {Change[]} changes
|
|
|
- * @param {Object} limits
|
|
|
|
|
* @param {number} endVersion
|
|
* @param {number} endVersion
|
|
|
* @param {Object} [options]
|
|
* @param {Object} [options]
|
|
|
* @param {boolean} [options.onlyIfExists] - If true, only queue changes if the project
|
|
* @param {boolean} [options.onlyIfExists] - If true, only queue changes if the project
|
|
|
* already exists in Redis.
|
|
* already exists in Redis.
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-async function queueChangesFake(
|
|
|
|
|
- projectId,
|
|
|
|
|
- changes,
|
|
|
|
|
- limits,
|
|
|
|
|
- endVersion,
|
|
|
|
|
- options = {}
|
|
|
|
|
-) {
|
|
|
|
|
|
|
+async function queueChangesFake(projectId, changes, endVersion, options = {}) {
|
|
|
try {
|
|
try {
|
|
|
await queueChanges(projectId, changes, endVersion)
|
|
await queueChanges(projectId, changes, endVersion)
|
|
|
await fakePersistRedisChanges(projectId, changes, endVersion)
|
|
await fakePersistRedisChanges(projectId, changes, endVersion)
|
|
@@ -107,17 +100,11 @@ async function queueChangesFake(
|
|
|
* Queues changes in Redis, simulating persistence, but only if the project already exists.
|
|
* Queues changes in Redis, simulating persistence, but only if the project already exists.
|
|
|
* @param {string} projectId - The ID of the project.
|
|
* @param {string} projectId - The ID of the project.
|
|
|
* @param {Change[]} changes - An array of changes to be queued.
|
|
* @param {Change[]} changes - An array of changes to be queued.
|
|
|
- * @param {Object} limits - Limits for the changes.
|
|
|
|
|
* @param {number} endVersion - The expected version of the project before these changes are applied.
|
|
* @param {number} endVersion - The expected version of the project before these changes are applied.
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-async function queueChangesFakeOnlyIfExists(
|
|
|
|
|
- projectId,
|
|
|
|
|
- changes,
|
|
|
|
|
- limits,
|
|
|
|
|
- endVersion
|
|
|
|
|
-) {
|
|
|
|
|
- await queueChangesFake(projectId, changes, limits, endVersion, {
|
|
|
|
|
|
|
+async function queueChangesFakeOnlyIfExists(projectId, changes, endVersion) {
|
|
|
|
|
+ await queueChangesFake(projectId, changes, endVersion, {
|
|
|
onlyIfExists: true,
|
|
onlyIfExists: true,
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|