rate-limiter: implement hypervisor-built-in rate limiter

As for hypervisors that support built-in rate limiter, like firecracker,
we use this built-in characteristics to implement rate limiter in kata.
kata-defined rate is in bits with scaling factors of 1000, otherwise fc-defined
rate is in bytes with scaling factors of 1024, so need reversion.

Fixes: #250

Signed-off-by: Penny Zheng <penny.zheng@arm.com>
This commit is contained in:
Penny Zheng
2020-06-16 05:40:27 +00:00
parent 676ad989d7
commit cfeb966763
4 changed files with 71 additions and 6 deletions

View File

@@ -19,17 +19,17 @@ type TokenBucket struct {
// The initial size of a token bucket.
// Minimum: 0
OneTimeBurst *int64 `json:"one_time_burst,omitempty"`
OneTimeBurst *uint64 `json:"one_time_burst,omitempty"`
// The amount of milliseconds it takes for the bucket to refill.
// Required: true
// Minimum: 0
RefillTime *int64 `json:"refill_time"`
RefillTime *uint64 `json:"refill_time"`
// The total number of tokens this bucket can hold.
// Required: true
// Minimum: 0
Size *int64 `json:"size"`
Size *uint64 `json:"size"`
}
// Validate validates this token bucket

View File

@@ -615,17 +615,17 @@ definitions:
properties:
size:
type: integer
format: int64
format: uint64
description: The total number of tokens this bucket can hold.
minimum: 0
one_time_burst:
type: integer
format: int64
format: uint64
description: The initial size of a token bucket.
minimum: 0
refill_time:
type: integer
format: int64
format: uint64
description: The amount of milliseconds it takes for the bucket to refill.
minimum: 0