aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2015-12-14 21:09:25 +0100
committerChocobozzz <florian.bigard@gmail.com>2015-12-14 22:13:03 +0100
commit656ea8f70e848b03c0b668584dd533d72b376498 (patch)
treefa49512e3a3702a80d027838e5ab7486baca185a /src/utils.js
parent1d7974c758d363a0037c2a7ed05a0848d3c027a4 (diff)
downloadPeerTube-656ea8f70e848b03c0b668584dd533d72b376498.tar.gz
PeerTube-656ea8f70e848b03c0b668584dd533d72b376498.tar.zst
PeerTube-656ea8f70e848b03c0b668584dd533d72b376498.zip
Create a constants module to easily modify some constants in a test
instance for example.
Diffstat (limited to 'src/utils.js')
-rw-r--r--src/utils.js9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/utils.js b/src/utils.js
index 30edcd0e9..5880c6c90 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -10,6 +10,7 @@
10 var replay = require('request-replay') 10 var replay = require('request-replay')
11 var ursa = require('ursa') 11 var ursa = require('ursa')
12 12
13 var constants = require('./constants')
13 var logger = require('./logger') 14 var logger = require('./logger')
14 15
15 var utils = {} 16 var utils = {}
@@ -31,15 +32,13 @@
31 } 32 }
32 33
33 logger.debug('Make retry requests to %s.', to_pod.url) 34 logger.debug('Make retry requests to %s.', to_pod.url)
34 // Default 10 but in tests we want to be faster
35 var retries = utils.isTestInstance() ? 2 : 10
36 35
37 replay( 36 replay(
38 request.post(params, function (err, response, body) { 37 request.post(params, function (err, response, body) {
39 callbackEach(err, response, body, params.url, to_pod) 38 callbackEach(err, response, body, params.url, to_pod)
40 }), 39 }),
41 { 40 {
42 retries: retries, 41 retries: constants.REQUEST_RETRIES,
43 factor: 3, 42 factor: 3,
44 maxTimeout: Infinity, 43 maxTimeout: Infinity,
45 errorCodes: [ 'EADDRINFO', 'ETIMEDOUT', 'ECONNRESET', 'ESOCKETTIMEDOUT', 'ENOTFOUND', 'ECONNREFUSED' ] 44 errorCodes: [ 'EADDRINFO', 'ETIMEDOUT', 'ECONNRESET', 'ESOCKETTIMEDOUT', 'ENOTFOUND', 'ECONNREFUSED' ]
@@ -195,9 +194,5 @@
195 process.kill(-webtorrent_process.pid) 194 process.kill(-webtorrent_process.pid)
196 } 195 }
197 196
198 utils.isTestInstance = function () {
199 return (process.env.NODE_ENV === 'test')
200 }
201
202 module.exports = utils 197 module.exports = utils
203})() 198})()