@tramvai/module-request-limiter 2.112.0 → 2.117.2

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.
@@ -37,14 +37,14 @@ class RequestLimiter {
37
37
  if (Number.isNaN(this.eventLoopDelay))
38
38
  this.eventLoopDelay = Infinity;
39
39
  this.eventLoopHistogram.reset();
40
- if (this.currentActive >= this.activeRequestLimit) {
41
- if (this.eventLoopDelay <= this.maxEventLoopDelay) {
40
+ if (this.eventLoopDelay <= this.maxEventLoopDelay) {
41
+ if (this.currentActive >= this.activeRequestLimit) {
42
42
  this.activeRequestLimit++;
43
- // We need to have minimalActiveRequestLimit
44
- }
45
- else if (this.activeRequestLimit > this.minimalActiveRequestLimit) {
46
- this.activeRequestLimit--;
47
43
  }
44
+ // We need to have minimalActiveRequestLimit
45
+ }
46
+ else if (this.activeRequestLimit > this.minimalActiveRequestLimit) {
47
+ this.activeRequestLimit--;
48
48
  }
49
49
  }
50
50
  add(request) {
@@ -46,14 +46,14 @@ class RequestLimiter {
46
46
  if (Number.isNaN(this.eventLoopDelay))
47
47
  this.eventLoopDelay = Infinity;
48
48
  this.eventLoopHistogram.reset();
49
- if (this.currentActive >= this.activeRequestLimit) {
50
- if (this.eventLoopDelay <= this.maxEventLoopDelay) {
49
+ if (this.eventLoopDelay <= this.maxEventLoopDelay) {
50
+ if (this.currentActive >= this.activeRequestLimit) {
51
51
  this.activeRequestLimit++;
52
- // We need to have minimalActiveRequestLimit
53
- }
54
- else if (this.activeRequestLimit > this.minimalActiveRequestLimit) {
55
- this.activeRequestLimit--;
56
52
  }
53
+ // We need to have minimalActiveRequestLimit
54
+ }
55
+ else if (this.activeRequestLimit > this.minimalActiveRequestLimit) {
56
+ this.activeRequestLimit--;
57
57
  }
58
58
  }
59
59
  add(request) {
package/lib/server.es.js CHANGED
@@ -4,7 +4,7 @@ import { ENV_USED_TOKEN, ENV_MANAGER_TOKEN } from '@tramvai/tokens-common';
4
4
  import { WEB_FASTIFY_APP_LIMITER_TOKEN } from '@tramvai/tokens-server-private';
5
5
  import { DEFAULT_OPTIONS, RequestLimiter, fastifyRequestsLimiter } from './requestLimiter.es.js';
6
6
  export { DEFAULT_OPTIONS, RequestLimiter, fastifyRequestsLimiter } from './requestLimiter.es.js';
7
- import { REQUESTS_LIMITER_OPTIONS_TOKEN, REQUESTS_LIMITER_TOKEN, REQUESTS_LIMITER_ACTIVATE_TOKEN } from './tokens.es.js';
7
+ import { REQUESTS_LIMITER_TOKEN, REQUESTS_LIMITER_OPTIONS_TOKEN, REQUESTS_LIMITER_ACTIVATE_TOKEN } from './tokens.es.js';
8
8
  export { REQUESTS_LIMITER_ACTIVATE_TOKEN, REQUESTS_LIMITER_OPTIONS_TOKEN, REQUESTS_LIMITER_TOKEN } from './tokens.es.js';
9
9
 
10
10
  let RequestLimiterModule = class RequestLimiterModule {
@@ -19,31 +19,17 @@ RequestLimiterModule = __decorate([
19
19
  {
20
20
  key: 'REQUEST_LIMITER_MELD',
21
21
  optional: true,
22
- value: String(DEFAULT_OPTIONS.maxEventLoopDelay),
23
22
  },
24
23
  {
25
24
  key: 'REQUEST_LIMITER_QUEUE',
26
25
  optional: true,
27
- value: String(DEFAULT_OPTIONS.queue),
28
26
  },
29
27
  {
30
28
  key: 'REQUEST_LIMITER_LIMIT',
31
29
  optional: true,
32
- value: String(DEFAULT_OPTIONS.limit),
33
30
  },
34
31
  ],
35
32
  }),
36
- provide({
37
- provide: REQUESTS_LIMITER_OPTIONS_TOKEN,
38
- useFactory: ({ envManager }) => ({
39
- maxEventLoopDelay: Number(envManager.get('REQUEST_LIMITER_MELD')),
40
- queue: Number(envManager.get('REQUEST_LIMITER_QUEUE')),
41
- limit: Number(envManager.get('REQUEST_LIMITER_LIMIT')),
42
- }),
43
- deps: {
44
- envManager: ENV_MANAGER_TOKEN,
45
- },
46
- }),
47
33
  provide({
48
34
  provide: REQUESTS_LIMITER_TOKEN,
49
35
  scope: Scope.SINGLETON,
package/lib/server.js CHANGED
@@ -21,31 +21,17 @@ exports.RequestLimiterModule = tslib.__decorate([
21
21
  {
22
22
  key: 'REQUEST_LIMITER_MELD',
23
23
  optional: true,
24
- value: String(requestLimiter.DEFAULT_OPTIONS.maxEventLoopDelay),
25
24
  },
26
25
  {
27
26
  key: 'REQUEST_LIMITER_QUEUE',
28
27
  optional: true,
29
- value: String(requestLimiter.DEFAULT_OPTIONS.queue),
30
28
  },
31
29
  {
32
30
  key: 'REQUEST_LIMITER_LIMIT',
33
31
  optional: true,
34
- value: String(requestLimiter.DEFAULT_OPTIONS.limit),
35
32
  },
36
33
  ],
37
34
  }),
38
- core.provide({
39
- provide: tokens.REQUESTS_LIMITER_OPTIONS_TOKEN,
40
- useFactory: ({ envManager }) => ({
41
- maxEventLoopDelay: Number(envManager.get('REQUEST_LIMITER_MELD')),
42
- queue: Number(envManager.get('REQUEST_LIMITER_QUEUE')),
43
- limit: Number(envManager.get('REQUEST_LIMITER_LIMIT')),
44
- }),
45
- deps: {
46
- envManager: tokensCommon.ENV_MANAGER_TOKEN,
47
- },
48
- }),
49
35
  core.provide({
50
36
  provide: tokens.REQUESTS_LIMITER_TOKEN,
51
37
  scope: core.Scope.SINGLETON,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-request-limiter",
3
- "version": "2.112.0",
3
+ "version": "2.117.2",
4
4
  "description": "Enable different rendering modes for pages",
5
5
  "main": "lib/server.js",
6
6
  "module": "lib/server.es.js",
@@ -30,9 +30,9 @@
30
30
  "devDependencies": {},
31
31
  "peerDependencies": {
32
32
  "@tinkoff/dippy": "0.8.15",
33
- "@tramvai/core": "2.112.0",
34
- "@tramvai/tokens-common": "2.112.0",
35
- "@tramvai/tokens-server-private": "2.112.0",
33
+ "@tramvai/core": "2.117.2",
34
+ "@tramvai/tokens-common": "2.117.2",
35
+ "@tramvai/tokens-server-private": "2.117.2",
36
36
  "fastify": "^4.6.0",
37
37
  "tslib": "^2.4.0"
38
38
  }