1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | const bottleneck_1 = __importDefault(require("bottleneck"));
|
7 | class RatelimitedKubernetesRESTClient {
|
8 | constructor(inner, limiter) {
|
9 | this.inner = inner;
|
10 | if (!limiter) {
|
11 | limiter = new bottleneck_1.default({
|
12 | maxConcurrent: 2,
|
13 | minTime: 200,
|
14 | });
|
15 | }
|
16 | this.limiter = limiter;
|
17 | }
|
18 | post(url, body) {
|
19 | return this.limiter.schedule(() => this.inner.post(url, body));
|
20 | }
|
21 | put(url, body) {
|
22 | return this.limiter.schedule(() => this.inner.put(url, body));
|
23 | }
|
24 | delete(url, opts, queryParams, body) {
|
25 | return this.limiter.schedule(() => this.inner.delete(url, opts, queryParams, body));
|
26 | }
|
27 | get(url, opts) {
|
28 | return this.limiter.schedule(() => this.inner.get(url, opts));
|
29 | }
|
30 | patch(url, body, patchKind) {
|
31 | return this.limiter.schedule(() => this.inner.patch(url, body, patchKind));
|
32 | }
|
33 | watch(url, onUpdate, onError, opts) {
|
34 | return this.limiter.schedule(() => this.inner.watch(url, onUpdate, onError, opts));
|
35 | }
|
36 | }
|
37 | exports.RatelimitedKubernetesRESTClient = RatelimitedKubernetesRESTClient;
|
38 |
|
\ | No newline at end of file |