@letarette/client 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/agent.js +6 -5
  2. package/package.json +1 -1
package/lib/agent.js CHANGED
@@ -39,10 +39,12 @@ class SearchAgent extends events_1.EventEmitter {
39
39
  if (this.client === null) {
40
40
  throw new Error("Must be connected");
41
41
  }
42
+ const numShards = yield this.getNumShards();
43
+ const shardedLimit = Math.max(1, Math.trunc(pageLimit / numShards));
42
44
  const req = {
43
45
  Query: query,
44
46
  Spaces: spaces,
45
- PageLimit: pageLimit,
47
+ PageLimit: shardedLimit,
46
48
  PageOffset: pageOffset,
47
49
  Autocorrect: false,
48
50
  };
@@ -54,7 +56,6 @@ class SearchAgent extends events_1.EventEmitter {
54
56
  }
55
57
  reject("Timeout waiting for search response");
56
58
  }, 2000);
57
- const shards = yield this.getNumShards();
58
59
  const inbox = this.client.createInbox();
59
60
  const responses = [];
60
61
  subscription = yield this.client.subscribe(inbox, (err, msg) => {
@@ -63,12 +64,12 @@ class SearchAgent extends events_1.EventEmitter {
63
64
  }
64
65
  const res = msg.data;
65
66
  responses.push(res);
66
- if (responses.length === shards) {
67
+ if (responses.length === numShards) {
67
68
  clearTimeout(timeout);
68
69
  resolve(responses);
69
70
  }
70
- }, { max: shards });
71
- subscription.unsubscribe(shards);
71
+ }, { max: numShards });
72
+ subscription.unsubscribe(numShards);
72
73
  this.client.publish(this.options.topic + ".q", req, inbox);
73
74
  }));
74
75
  const result = yield request;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letarette/client",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/erkkah/letarette.js"