scale rate limit dripRate with factor
This commit is contained in:
parent
51ad31b5a4
commit
9ac58e6107
3 changed files with 28 additions and 12 deletions
|
|
@ -81,7 +81,7 @@ The Atomic Leaky Bucket algorithm is described here, in pseudocode:
|
|||
# * Delta Timestamp - Difference between current and expected timestamp value
|
||||
|
||||
# 0 - Calculations
|
||||
dripRate = ceil(limit.dripRate ?? 1000);
|
||||
dripRate = ceil((limit.dripRate ?? 1000) * factor);
|
||||
dripSize = ceil(limit.dripSize ?? 1);
|
||||
bucketSize = max(ceil(limit.size / factor), 1);
|
||||
maxExpiration = max(ceil((dripRate * ceil(bucketSize / dripSize)) / 1000), 1);;
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ export class SkRateLimiterService {
|
|||
// 0 - Calculate
|
||||
const now = this.timeService.now;
|
||||
const bucketSize = Math.max(Math.ceil(limit.size / factor), 1);
|
||||
const dripRate = Math.ceil(limit.dripRate ?? 1000);
|
||||
const dripRate = Math.ceil((limit.dripRate ?? 1000) * factor);
|
||||
const dripSize = Math.ceil(limit.dripSize ?? 1);
|
||||
const fullResetMs = dripRate * Math.ceil(bucketSize / dripSize);
|
||||
const fullResetSec = Math.max(Math.ceil(fullResetMs / 1000), 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue