Comparing version 1.0.7 to 1.0.8
@@ -70,2 +70,5 @@ "use strict"; | ||
} | ||
if (this.searchHostType === 'CONSUL') { | ||
this.protocol = 'THRIFT'; | ||
} | ||
return this.protocol; | ||
@@ -72,0 +75,0 @@ }; |
@@ -37,7 +37,10 @@ "use strict"; | ||
Consul.prototype.checkEnv = function (tags, env) { | ||
tags.forEach(function (tag) { | ||
if (tag.indexOf('env:') === 0 && tag === ('env:' + env)) { | ||
return true; | ||
if (Array.isArray(tags)) { | ||
for (var i = 0; i < tags.length; i++) { | ||
var tag = tags[i]; | ||
if (tag.indexOf('env:') === 0 && tag === ('env:' + env)) { | ||
return true; | ||
} | ||
} | ||
}); | ||
} | ||
return false; | ||
@@ -44,0 +47,0 @@ }; |
{ | ||
"name": "kitejs", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "the rpc framework Kite for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -86,10 +86,10 @@ # kitejs | ||
- protocol 访问协议,HTTP \ THRIFT | ||
- searchHostType 寻址方式 LOCAL 或者 CONSUL | ||
- protocol 访问协议,HTTP \ THRIFT,默认**HTTP** | ||
- searchHostType 寻址方式 LOCAL 或者 CONSUL,默认**LOCAL** | ||
- service consul 时提供 PSM 信息 | ||
- host 服务端域名信息 | ||
- port 服务端端口信息 | ||
- timeout 访问超时时间 1s 100ms or 1 默认为秒 | ||
- address 更人性化的地址设置,比如 127.0.0.1:1010 | ||
- consul | ||
- timeout 访问超时时间 `1s` `100ms` or `1` 默认为**秒** | ||
- address 更人性化的地址设置,比如 `127.0.0.1:10220` | ||
- consul 提供 consul 服务地址信息 | ||
@@ -107,14 +107,27 @@ ```js | ||
``` | ||
.request(options?, cb); | ||
``` | ||
参数 | ||
```js | ||
function (err, data, conn?) {} | ||
``` | ||
- err 如果发生错误,err 为 Error 对象实例,如果未发生错误为 `null` | ||
- data | ||
- protocol=THRIFT 时,返回 Service 对象 | ||
- protocol=HTTP 时,直接返回请求 response 的内容 | ||
- conn 可选参数,如果 THRIFT 时,返回请求 connection ,可以方便 Service 获取到数据后关闭连接。 | ||
- options 可选,主要用于 HTTP 填写 PATH、HEADERS 等信息 | ||
- path 访问 path | ||
- method 默认为 **GET** | ||
- data `POST` 数据 | ||
- headers 请求头信息 | ||
- cb | ||
```js | ||
function (err, data, conn?) {} | ||
``` | ||
- err 如果发生错误,err 为 Error 对象实例,如果未发生错误为 `null` | ||
- data | ||
- protocol=THRIFT 时,返回 Service 对象 | ||
- protocol=HTTP 时,直接返回请求 response 的内容 | ||
- conn 可选参数,如果 THRIFT 时,返回请求 connection ,可以方便 Service 获取到数据后关闭连接。 | ||
### Client.`loadService` 加载 Thrift Service | ||
@@ -121,0 +134,0 @@ |
@@ -89,2 +89,6 @@ /** | ||
if (this.searchHostType === 'CONSUL') { | ||
this.protocol = 'THRIFT'; | ||
} | ||
return this.protocol; | ||
@@ -91,0 +95,0 @@ } |
@@ -45,8 +45,11 @@ import {Address} from './protocol/protocol'; | ||
private checkEnv(tags: Array<string>, env: string) { | ||
tags.forEach(tag => { | ||
if (tag.indexOf('env:') === 0 && tag === ('env:' + env)) { | ||
return true; | ||
if (Array.isArray(tags)) { | ||
for (let i = 0; i < tags.length; i++) { | ||
let tag = tags[i]; | ||
if (tag.indexOf('env:') === 0 && tag === ('env:' + env)) { | ||
return true; | ||
} | ||
} | ||
}); | ||
} | ||
return false; | ||
@@ -53,0 +56,0 @@ } |
Sorry, the diff of this file is not supported yet
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
38826
979
143