Comparing version 1.0.13 to 1.0.14
@@ -9,2 +9,3 @@ "use strict"; | ||
function Consul() { | ||
this.useCheckEnv = true; | ||
} | ||
@@ -16,2 +17,5 @@ Consul.prototype.get = function (serAddress, service, callback, env, idc) { | ||
} | ||
if (typeof env !== 'string') { | ||
this.useCheckEnv = false; | ||
} | ||
debug("start_request host: " + serAddress.getHost + " port: " + serAddress.getPort()); | ||
@@ -22,3 +26,3 @@ var consul = NConsul({ | ||
}); | ||
var that = this; | ||
var __this = this; | ||
consul.catalog.service.nodes({ | ||
@@ -31,3 +35,3 @@ service: service | ||
nodes.forEach(function (node) { | ||
if (!that.checkEnv(node.ServiceTags, env)) { | ||
if (__this.useCheckEnv && !__this.checkEnv(node.ServiceTags, env)) { | ||
return; | ||
@@ -49,3 +53,3 @@ } | ||
} | ||
return true; | ||
return false; | ||
}; | ||
@@ -52,0 +56,0 @@ return Consul; |
{ | ||
"name": "kitejs", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"description": "the rpc framework Kite for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,2 +8,4 @@ import {Address} from './protocol/protocol'; | ||
export class Consul { | ||
useCheckEnv: boolean = true; | ||
public get(serAddress: Address, service: string, callback, env: string = 'prod', idc ?: string) { | ||
@@ -14,3 +16,8 @@ if (!service) { | ||
if (typeof env !== 'string') { | ||
this.useCheckEnv = false; | ||
} | ||
debug(`start_request host: ${serAddress.getHost} port: ${serAddress.getPort()}`); | ||
const consul = NConsul({ | ||
@@ -21,3 +28,3 @@ host: serAddress.getHost(), | ||
var that = this; | ||
var __this = this; | ||
@@ -32,3 +39,3 @@ consul.catalog.service.nodes( | ||
nodes.forEach(node => { | ||
if (!that.checkEnv(node.ServiceTags, env)) { | ||
if (__this.useCheckEnv && !__this.checkEnv(node.ServiceTags, env)) { | ||
return; | ||
@@ -58,3 +65,3 @@ } | ||
return true; | ||
return false; | ||
} | ||
@@ -61,0 +68,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52182
1361