Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #6 from Voxer/master
Browse files Browse the repository at this point in the history
Add a maxRetries option
  • Loading branch information
dannycoates committed Nov 16, 2012
2 parents 634d9bc + 2a51e50 commit 720a9ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/request_set.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 720a9ee

Please sign in to comment.