@miso.ai/server-commons 0.6.5-beta.10 → 0.6.5-beta.12

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/package.json +1 -1
  2. package/src/sink/bps.js +8 -1
package/package.json CHANGED
@@ -21,5 +21,5 @@
21
21
  "uuid": "^9.0.0",
22
22
  "yargs": "^17.5.1"
23
23
  },
24
- "version": "0.6.5-beta.10"
24
+ "version": "0.6.5-beta.12"
25
25
  }
package/src/sink/bps.js CHANGED
@@ -11,11 +11,13 @@ export default class BpsSink {
11
11
  }
12
12
 
13
13
  _normalizeOptions({
14
+ writesPerSecond = 10,
14
15
  recordsPerSecord = 100000,
15
16
  bytesPerSecond = 100 * 1024 * 1024,
16
17
  ...options
17
18
  } = {}) {
18
19
  return {
20
+ writesPerSecond,
19
21
  recordsPerSecord,
20
22
  bytesPerSecond,
21
23
  ...options,
@@ -62,9 +64,10 @@ export default class BpsSink {
62
64
  const elapsed = now - this._firstWriteAt;
63
65
  const targetBps = this._targetBps(now);
64
66
  const targetRps = this._targetRps(now);
67
+ const targetWps = this._targetWps(now);
65
68
 
66
69
  const { started } = this._stats;
67
- const shallElapsed = Math.max(started.records / targetRps, started.bytes / targetBps) * 1000;
70
+ const shallElapsed = Math.max(started.records / targetRps, started.bytes / targetBps, started.count / targetWps) * 1000;
68
71
 
69
72
  const blockedTime = shallElapsed - elapsed;
70
73
  if (blockedTime <= 1000) {
@@ -86,4 +89,8 @@ export default class BpsSink {
86
89
  return this._options.recordsPerSecord;
87
90
  }
88
91
 
92
+ _targetWps(timestamp) {
93
+ return this._options.writesPerSecord;
94
+ }
95
+
89
96
  }