1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Remove "function" in favor of () => {}

This commit is contained in:
Chocobozzz 2017-07-11 17:04:57 +02:00
parent 4e979c3e1b
commit 075f16caac
25 changed files with 85 additions and 90 deletions

View file

@ -8,13 +8,11 @@ type RetryTransactionWrapperOptions = { errorMessage: string, arguments?: any[]
function retryTransactionWrapper (functionToRetry: (... args) => Promise<any>, options: RetryTransactionWrapperOptions) {
const args = options.arguments ? options.arguments : []
return transactionRetryer(
function (callback) {
functionToRetry.apply(this, args)
return transactionRetryer(callback => {
functionToRetry.apply(this, args)
.then(result => callback(null, result))
.catch(err => callback(err))
}
)
})
.catch(err => {
// Do not throw the error, continue the process
logger.error(options.errorMessage, err)
@ -26,14 +24,12 @@ function transactionRetryer (func: Function) {
retry({
times: 5,
errorFilter: function (err) {
errorFilter: err => {
const willRetry = (err.name === 'SequelizeDatabaseError')
logger.debug('Maybe retrying the transaction function.', { willRetry })
return willRetry
}
}, func, function (err) {
err ? rej(err) : res()
})
}, func, err => err ? rej(err) : res())
})
}