Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #6 from Voxer/master

Add a maxRetries option
  • Loading branch information...
commit 720a9eed29b2723b4dc4777aa1419f9a2f8b77f7 2 parents 634d9bc + 2a51e50
Danny Coates authored
Showing with 4 additions and 1 deletion.
  1. +3 −0  lib/pool.js
  2. +1 −1  lib/request_set.js
3  lib/pool.js
View
@@ -10,9 +10,11 @@ module.exports = function (inherits, EventEmitter, Endpoint, RequestSet) {
// {
// maxPending: number of pending requests allowed (1000)
// ping: ping path (default = no ping checks)
+ // pingTimeout: number (milliseconds) default 2000
// retryFilter: function (response) { return true to reject response and retry }
// retryDelay: number (milliseconds) default 20
// name: string (optional)
+ // maxRetries: number (default = 5)
// }
function Pool(http, nodes, options) {
options = options || {}
@@ -23,6 +25,7 @@ module.exports = function (inherits, EventEmitter, Endpoint, RequestSet) {
options.retryFilter = options.retryFilter || options.retry_filter
options.retryDelay = options.retryDelay || options.retry_delay
options.ping = options.ping || options.path
+ options.maxRetries = options.maxRetries === 0 ? 0 : options.maxRetries || 5
if (!options.retryDelay && options.retryDelay !== 0) {
options.retryDelay = 20
2  lib/request_set.js
View
@@ -34,7 +34,7 @@ function attemptsFu(options, pool) {
if (options.data instanceof Stream) {
return 1
}
- return options.attempts || Math.min(5, Math.max(pool.length, 2))
+ return options.attempts || Math.min(pool.options.maxRetries, Math.max(pool.length, 2))
}
function exponentialBackoff(attempt, delay) {
Please sign in to comment.
Something went wrong with that request. Please try again.