@glimt/record 0.0.68 → 0.0.70
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.
- package/dist/record.cjs +64 -8
- package/dist/record.cjs.map +1 -1
- package/dist/record.js +64 -8
- package/dist/record.js.map +1 -1
- package/dist/record.umd.cjs +64 -8
- package/dist/record.umd.cjs.map +2 -2
- package/dist/record.umd.min.cjs +21 -21
- package/dist/record.umd.min.cjs.map +2 -2
- package/package.json +1 -1
package/dist/record.js
CHANGED
|
@@ -10328,9 +10328,13 @@ const stormSnapshotManager = new StormSnapshotManager();
|
|
|
10328
10328
|
const _MutationRateLimiter = class _MutationRateLimiter2 {
|
|
10329
10329
|
constructor() {
|
|
10330
10330
|
__publicField(this, "mutTracker");
|
|
10331
|
+
__publicField(this, "exitMutTracker");
|
|
10331
10332
|
__publicField(this, "interval", 50);
|
|
10332
|
-
__publicField(this, "
|
|
10333
|
+
__publicField(this, "exitInterval", 100);
|
|
10334
|
+
__publicField(this, "mutThreshold", 100);
|
|
10333
10335
|
__publicField(this, "inGlobalStorm", false);
|
|
10336
|
+
__publicField(this, "currentStormStartedAt", -1);
|
|
10337
|
+
__publicField(this, "stormTimeLimit", 5e3);
|
|
10334
10338
|
if (_MutationRateLimiter2.instance) {
|
|
10335
10339
|
return _MutationRateLimiter2.instance;
|
|
10336
10340
|
}
|
|
@@ -10338,23 +10342,75 @@ const _MutationRateLimiter = class _MutationRateLimiter2 {
|
|
|
10338
10342
|
debugLog(`MutationRateLimiter, init`);
|
|
10339
10343
|
this.reset();
|
|
10340
10344
|
}
|
|
10341
|
-
|
|
10345
|
+
resetTracker() {
|
|
10342
10346
|
this.mutTracker = {
|
|
10343
10347
|
muts: 0,
|
|
10344
10348
|
ts: -1
|
|
10345
10349
|
};
|
|
10346
10350
|
}
|
|
10351
|
+
resetExitTracker() {
|
|
10352
|
+
this.exitMutTracker = {
|
|
10353
|
+
muts: 0,
|
|
10354
|
+
requested: -1
|
|
10355
|
+
};
|
|
10356
|
+
}
|
|
10357
|
+
reset() {
|
|
10358
|
+
this.resetTracker();
|
|
10359
|
+
this.resetExitTracker();
|
|
10360
|
+
this.currentStormStartedAt = -1;
|
|
10361
|
+
}
|
|
10362
|
+
stormStopped() {
|
|
10363
|
+
this.inGlobalStorm = false;
|
|
10364
|
+
this.reset();
|
|
10365
|
+
}
|
|
10366
|
+
handleStormExit(muts) {
|
|
10367
|
+
const now = Date.now();
|
|
10368
|
+
if (this.exitMutTracker.requested === -1) {
|
|
10369
|
+
this.exitMutTracker = {
|
|
10370
|
+
requested: now,
|
|
10371
|
+
muts
|
|
10372
|
+
};
|
|
10373
|
+
} else {
|
|
10374
|
+
this.exitMutTracker.muts += muts;
|
|
10375
|
+
if (now - this.exitMutTracker.requested > this.exitInterval) {
|
|
10376
|
+
if (this.exitMutTracker.muts >= this.mutThreshold) {
|
|
10377
|
+
debugLog(
|
|
10378
|
+
`MutationRateLimiter, exit cooldown failed, continuing with storm`,
|
|
10379
|
+
{
|
|
10380
|
+
mutTracker: this.mutTracker,
|
|
10381
|
+
exitMutTracker: this.exitMutTracker
|
|
10382
|
+
}
|
|
10383
|
+
);
|
|
10384
|
+
this.mutTracker.ts = now;
|
|
10385
|
+
this.mutTracker.muts += this.exitMutTracker.muts;
|
|
10386
|
+
this.resetExitTracker();
|
|
10387
|
+
return true;
|
|
10388
|
+
} else {
|
|
10389
|
+
debugLog(`MutationRateLimiter, detected global storm exit.`, {
|
|
10390
|
+
mutTracker: this.mutTracker,
|
|
10391
|
+
exitMutTracker: this.exitMutTracker
|
|
10392
|
+
});
|
|
10393
|
+
this.stormStopped();
|
|
10394
|
+
return false;
|
|
10395
|
+
}
|
|
10396
|
+
}
|
|
10397
|
+
}
|
|
10398
|
+
return true;
|
|
10399
|
+
}
|
|
10347
10400
|
isStorming(muts) {
|
|
10348
10401
|
const now = Date.now();
|
|
10349
10402
|
if (this.inGlobalStorm) {
|
|
10350
|
-
this.
|
|
10351
|
-
if (now - this.mutTracker.ts > this.interval) {
|
|
10352
|
-
this.inGlobalStorm = false;
|
|
10403
|
+
if (now - this.currentStormStartedAt > this.stormTimeLimit) {
|
|
10353
10404
|
debugLog(
|
|
10354
|
-
`MutationRateLimiter,
|
|
10405
|
+
`MutationRateLimiter, storm time limit reached, stopping storm`
|
|
10355
10406
|
);
|
|
10407
|
+
this.stormStopped();
|
|
10356
10408
|
return false;
|
|
10357
10409
|
}
|
|
10410
|
+
if (now - this.mutTracker.ts > this.interval) {
|
|
10411
|
+
return this.handleStormExit(muts);
|
|
10412
|
+
}
|
|
10413
|
+
this.mutTracker.muts += muts;
|
|
10358
10414
|
this.mutTracker.ts = now;
|
|
10359
10415
|
return true;
|
|
10360
10416
|
}
|
|
@@ -10363,10 +10419,10 @@ const _MutationRateLimiter = class _MutationRateLimiter2 {
|
|
|
10363
10419
|
} else {
|
|
10364
10420
|
if (now - this.mutTracker.ts <= this.interval) {
|
|
10365
10421
|
this.mutTracker.muts += muts;
|
|
10366
|
-
if (this.mutTracker.muts >= this.
|
|
10422
|
+
if (this.mutTracker.muts >= this.mutThreshold) {
|
|
10367
10423
|
this.inGlobalStorm = true;
|
|
10368
|
-
this.reset();
|
|
10369
10424
|
debugLog(`MutationRateLimiter, detected global rolling storm`);
|
|
10425
|
+
this.currentStormStartedAt = now;
|
|
10370
10426
|
return true;
|
|
10371
10427
|
}
|
|
10372
10428
|
}
|