Skip to content

Commit

Permalink
Incorporated review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Shubhendu Ram Tripathi <[email protected]>
  • Loading branch information
shtripat committed Dec 11, 2023
1 parent 1181b03 commit a39fd4f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 114 deletions.
25 changes: 20 additions & 5 deletions quota-commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,20 @@ func (t QuotaType) IsValid() bool {
return t == HardQuota
}

// BucketThrottleRule holds a bucket throttle rule
type BucketThrottleRule struct {
ConcurrentRequestsCount uint64 `json:"concurrentRequestsCount"` // indicates no of concurrent requests
APIs []string `json:"apis"` // indicates list of APIs
}

// BucketQuota holds bucket quota restrictions
type BucketQuota struct {
Quota uint64 `json:"quota"` // Deprecated Aug 2023
Size uint64 `json:"size"` // Indicates maximum size allowed per bucket
Rate uint64 `json:"rate"` // Indicates bandwidth rate allocated per bucket
Requests uint64 `json:"requests"` // Indicates number of requests allocated per bucket
Type QuotaType `json:"quotatype,omitempty"`
Quota uint64 `json:"quota"` // Deprecated Aug 2023
Size uint64 `json:"size"` // Indicates maximum size allowed per bucket
Rate uint64 `json:"rate"` // Indicates bandwidth rate allocated per bucket
Requests uint64 `json:"requests"` // Indicates number of requests allocated per bucket
Type QuotaType `json:"quotatype,omitempty"`
ThrottleRules []BucketThrottleRule `json:"throttleRules"` // indocates list of throttle rules per bucket
}

// IsValid returns false if quota is invalid
Expand All @@ -55,6 +62,14 @@ func (q BucketQuota) IsValid() bool {
if q.Quota > 0 {
return q.Type.IsValid()
}
if len(q.ThrottleRules) > 0 {
// if any throttle rule invalid, return false
for _, rule := range q.ThrottleRules {
if rule.ConcurrentRequestsCount <= 0 || len(rule.APIs) <= 0 {
return false
}
}
}
// Empty configs are valid.
return true
}
Expand Down
109 changes: 0 additions & 109 deletions throttle-commands.go

This file was deleted.

0 comments on commit a39fd4f

Please sign in to comment.