Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vladimir Buhtoyarov
committed
May 5, 2024
1 parent
1a47b97
commit 0f1f815
Showing
4 changed files
with
67 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
export class Bandwidth { | ||
|
||
public static readonly UNDEFINED_ID:string? = null; | ||
public static readonly UNSPECIFIED_TIME_OF_FIRST_REFILL:bigint = BigInt(0); | ||
|
||
private readonly capacity:bigint | ||
private readonly initialTokens:bigint | ||
private readonly refillPeriodNanos:bigint | ||
private readonly refillTokens:bigint | ||
private readonly refillIntervally:boolean | ||
private readonly timeOfFirstRefillMillis:bigint | ||
private readonly useAdaptiveInitialTokens:boolean | ||
private readonly id:string | ||
|
||
constructor(capacity:bigint, refillPeriodNanos:bigint, refillTokens:bigint, initialTokens:bigint, refillIntervally:boolean, | ||
timeOfFirstRefillMillis:bigint, useAdaptiveInitialTokens:boolean, id:string) { | ||
this.capacity = capacity; | ||
this.initialTokens = initialTokens; | ||
this.refillPeriodNanos = refillPeriodNanos; | ||
this.refillTokens = refillTokens; | ||
this.refillIntervally = refillIntervally; | ||
this.timeOfFirstRefillMillis = timeOfFirstRefillMillis; | ||
this.useAdaptiveInitialTokens = useAdaptiveInitialTokens; | ||
this.id = id; | ||
} | ||
|
||
public isIntervallyAligned():boolean { | ||
return this.timeOfFirstRefillMillis != Bandwidth.UNSPECIFIED_TIME_OF_FIRST_REFILL; | ||
} | ||
|
||
public getTimeOfFirstRefillMillis():bigint { | ||
return this.timeOfFirstRefillMillis; | ||
} | ||
|
||
public getCapacity():bigint { | ||
return this.capacity; | ||
} | ||
|
||
public getInitialTokens():bigint { | ||
return this.initialTokens; | ||
} | ||
|
||
public getRefillPeriodNanos():bigint { | ||
return this.refillPeriodNanos; | ||
} | ||
|
||
public getRefillTokens():bigint { | ||
return this.refillTokens; | ||
} | ||
|
||
public isUseAdaptiveInitialTokens():boolean { | ||
return this.useAdaptiveInitialTokens; | ||
} | ||
|
||
public isRefillIntervally():boolean { | ||
return this.refillIntervally; | ||
} | ||
|
||
public isGready():boolean { | ||
return !this.refillIntervally; | ||
} | ||
|
||
public getId():string { | ||
return this.id; | ||
} | ||
} |