multiple-redis
Advanced tools
Comparing version 1.2.0 to 1.2.1
| Date | Version | Description | | ||
| ----------- | ------- | ----------- | | ||
| 2019-06-21 | v1.2.0 | Added 'forceParallel' option to issue GET in parallel #5 | | ||
| 2019-06-24 | v1.2.1 | Added 'forceParallel' option to issue GET in parallel #5 | | ||
| 2017-07-26 | v1.0.61 | Added all-ready event and allConnected attribute | | ||
@@ -5,0 +5,0 @@ | 2017-01-18 | v1.0.29 | setnx type commands now run in sequence and not in parallel | |
@@ -396,2 +396,32 @@ 'use strict'; | ||
/** | ||
* Similar to race but stops on the first valid output. | ||
* | ||
* @function | ||
* @memberof! MultiRedisClient | ||
* @alias MultiRedisClient.parallelOnFirstValid | ||
* @private | ||
* @param {Array} actions - Functions array to invoke | ||
* @param {function} callback - Invoked on first valid output. | ||
*/ | ||
function parallelOnFirstValid(actions, callback) { | ||
asyncLib.parallel(actions.map(function modifyAction(action) { | ||
return function onAction(cb) { | ||
action(function onActionDone(error, value) { | ||
if (value) { | ||
cb(value); | ||
} else { | ||
cb(null, error); | ||
} | ||
}); | ||
}; | ||
}), function onParallelDone(value, errors) { | ||
if (value) { | ||
callback(null, value); | ||
} else { | ||
callback(errors); | ||
} | ||
}); | ||
} | ||
/** | ||
* Creates and returns a handler function for the given command. | ||
@@ -466,3 +496,7 @@ * | ||
if (runInParallel || self.forceParallel) { | ||
asyncLib.parallel(actions, onRedisFlowEnd); | ||
if (getCommand) { | ||
parallelOnFirstValid(actions, onRedisFlowEnd); | ||
} else { | ||
asyncLib.parallel(actions, onRedisFlowEnd); | ||
} | ||
} else { | ||
@@ -469,0 +503,0 @@ asyncLib.series(actions, onRedisFlowEnd); |
{ | ||
"name": "multiple-redis", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Run redis commands against multiple redis instances.", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -140,3 +140,3 @@ # multiple-redis | ||
| ----------- | ------- | ----------- | | ||
| 2019-06-21 | v1.2.0 | Added 'forceParallel' option to issue GET in parallel #5 | | ||
| 2019-06-24 | v1.2.1 | Added 'forceParallel' option to issue GET in parallel #5 | | ||
| 2017-07-26 | v1.0.61 | Added all-ready event and allConnected attribute | | ||
@@ -143,0 +143,0 @@ | 2017-01-18 | v1.0.29 | setnx type commands now run in sequence and not in parallel | |
65019
813