1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 10:49:28 +02:00

Server: retryer transaction wrapper refractoring

This commit is contained in:
Chocobozzz 2017-01-15 19:13:16 +01:00
parent a7721e62c0
commit d6a5b018b8
4 changed files with 51 additions and 50 deletions

View file

@ -66,19 +66,12 @@ function remoteVideos (req, res, next) {
// Handle retries on fail
function addRemoteVideoRetryWrapper (videoToCreateData, fromPod, finalCallback) {
utils.transactionRetryer(
function (callback) {
return addRemoteVideo(videoToCreateData, fromPod, callback)
},
function (err) {
if (err) {
logger.error('Cannot insert the remote video with many retries.', { error: err })
}
const options = {
arguments: [ videoToCreateData, fromPod ],
errorMessage: 'Cannot insert the remote video with many retries.'
}
// Do not return the error, continue the process
return finalCallback(null)
}
)
utils.retryWrapper(addRemoteVideo, options, finalCallback)
}
function addRemoteVideo (videoToCreateData, fromPod, finalCallback) {
@ -182,19 +175,12 @@ function addRemoteVideo (videoToCreateData, fromPod, finalCallback) {
// Handle retries on fail
function updateRemoteVideoRetryWrapper (videoAttributesToUpdate, fromPod, finalCallback) {
utils.transactionRetryer(
function (callback) {
return updateRemoteVideo(videoAttributesToUpdate, fromPod, callback)
},
function (err) {
if (err) {
logger.error('Cannot update the remote video with many retries.', { error: err })
}
const options = {
arguments: [ fromPod, videoAttributesToUpdate ],
errorMessage: 'Cannot update the remote video with many retries'
}
// Do not return the error, continue the process
return finalCallback(null)
}
)
utils.retryWrapper(updateRemoteVideo, options, finalCallback)
}
function updateRemoteVideo (videoAttributesToUpdate, fromPod, finalCallback) {