Skip to content

Commit cc13b11

Browse files
author
zhaoxuebin
committed
tiomeout
1 parent 6dccf6d commit cc13b11

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ let ret = await demoIndex
270270
```js
271271
instance.set("log",console.log);
272272
```
273+
设置请求超时时间,以毫秒为单位(默认是30s)
274+
```js
275+
instance.set('timeout',5000);
276+
```
273277
## 查询API
274278
### 文本匹配
275279
#### match 查询

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "elasticsearch-orm",
3-
"version": "1.0.18",
3+
"version": "1.0.19",
44
"description": "This is a orm for elasticSearch",
55
"main": "es.js",
66
"scripts": {

util/globalConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
const map = new Map();
22
map.set('scroll', '1m');
3+
map.set('timeout', 30 * 1000);
34
module.exports = map;

util/request.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ const initContentType = (opts) => {
1212
module.exports = (opts) => {
1313
const DEBUG = config.get('debug');
1414
const log = config.get("log") || console.log;
15+
const TIMEOUT = config.get('timeout');
1516
initContentType(opts);
17+
if (!opts.timeout) {
18+
opts.timeout = TIMEOUT;
19+
}
1620
let logArr = [];
1721
return new Promise((resolve, reject) => {
1822
if (DEBUG) {

0 commit comments

Comments
 (0)