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