aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/utils.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/server/helpers/utils.js b/server/helpers/utils.js
index a902850cd..fb4dd08cc 100644
--- a/server/helpers/utils.js
+++ b/server/helpers/utils.js
@@ -11,6 +11,7 @@ const utils = {
11 generateRandomString, 11 generateRandomString,
12 isTestInstance, 12 isTestInstance,
13 getFormatedObjects, 13 getFormatedObjects,
14 retryWrapper,
14 transactionRetryer 15 transactionRetryer
15} 16}
16 17
@@ -48,6 +49,25 @@ function getFormatedObjects (objects, objectsTotal) {
48 } 49 }
49} 50}
50 51
52// { arguments, errorMessage }
53function retryWrapper (functionToRetry, options, finalCallback) {
54 const args = options.arguments ? options.arguments : []
55
56 utils.transactionRetryer(
57 function (callback) {
58 return functionToRetry.apply(this, args.concat([ callback ]))
59 },
60 function (err) {
61 if (err) {
62 logger.error(options.errorMessage, { error: err })
63 }
64
65 // Do not return the error, continue the process
66 return finalCallback(null)
67 }
68 )
69}
70
51function transactionRetryer (func, callback) { 71function transactionRetryer (func, callback) {
52 retry({ 72 retry({
53 times: 5, 73 times: 5,