Skip to content

Commit

Permalink
change to right license and update to type safe operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Gurtzick committed Mar 21, 2017
1 parent 63df6a9 commit be65519
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/econ-refused/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"main": "econ-refused.js",
"author": "",
"license": "ISC",
"license": "MIT",
"dependencies": {
"async": "^2.1.5",
"request": "^2.79.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/low-response-time/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"main": "low-latency.js",
"author": "",
"license": "ISC",
"license": "MIT",
"dependencies": {
"async": "^2.1.5"
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"url": "https://github.com/rjrodger/visigoth.git"
},
"author": "",
"license": "ISC",
"license": "MIT",
"bugs": {
"url": "https://github.com/rjrodger/visigoth/issues"
},
Expand Down
12 changes: 6 additions & 6 deletions visigoth.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function api_remove_by(callback) {
*/
function api_choose_all(callback) {
_(me.upstreams$).forEach(function(upstream, index) {
if (upstream.meta$.status != "CLOSED") {
if (upstream.meta$.status !== "CLOSED") {
callback(upstream, index);
}
});
Expand All @@ -106,7 +106,7 @@ function api_choose(callback) {

_(me.upstreams$).forEach(function(upstream, index) {
// Re-closing if the timeout has expired;
if (upstream.meta$.status == 'OPEN') {
if (upstream.meta$.status === 'OPEN') {
if ((Date.now() - upstream.meta$.statusTimestamp) > me.closingTimeout$) {
upstream.meta$.status = 'HALF-OPEN';
upstream.meta$.statusTimestamp = Date.now();
Expand All @@ -117,19 +117,19 @@ function api_choose(callback) {
upstream.meta$.status = 'OPEN';
upstream.meta$.statusTimestamp = Date.now();
}
if (current > bestScore && upstream.meta$.status != "OPEN") {
if (current > bestScore && upstream.meta$.status !== "OPEN") {
bestScore = current;
bestNode = index;
}
});

if (bestScore > 0) {
me.upstreams$[bestNode].meta$.lastChoosenTimestamp = Date.now();
me.lastChoosenIndex$ = bestNode;

callback(null, me.upstreams$[bestNode].target, this.failureStrategy$(me.upstreams$[bestNode]), me.upstreams$[bestNode].meta$.stats);
// Close the circuit once it has been successful
if (me.upstreams$[bestNode].meta$.status == "HALF-OPEN") {
if (me.upstreams$[bestNode].meta$.status === "HALF-OPEN") {
me.upstreams$[bestNode].meta$.status = "CLOSED";
me.upstreams$[bestNode].meta$.statusTimestamp = Date.now();
}
Expand Down

0 comments on commit be65519

Please sign in to comment.