Documentation ¶
Index ¶
- func TraverseRateLimiterTree(root *RateLimiterNode, ...)
- type RateLimiterNode
- func (rln *RateLimiterNode) AddChild(key int64, child *RateLimiterNode)
- func (rln *RateLimiterNode) Cancel(rt internalpb.RateType, n int)
- func (rln *RateLimiterNode) Check(rt internalpb.RateType, n int) error
- func (rln *RateLimiterNode) GetChild(key int64) *RateLimiterNode
- func (rln *RateLimiterNode) GetChildren() *typeutil.ConcurrentMap[int64, *RateLimiterNode]
- func (rln *RateLimiterNode) GetID() int64
- func (rln *RateLimiterNode) GetLimiters() *typeutil.ConcurrentMap[internalpb.RateType, *ratelimitutil.Limiter]
- func (rln *RateLimiterNode) GetQuotaExceededError(rt internalpb.RateType) error
- func (rln *RateLimiterNode) GetQuotaStates() *typeutil.ConcurrentMap[milvuspb.QuotaState, commonpb.ErrorCode]
- func (rln *RateLimiterNode) GetRateLimitError(rate float64) error
- func (rln *RateLimiterNode) Level() internalpb.RateScope
- func (rln *RateLimiterNode) Limit(rt internalpb.RateType, n int) (bool, float64)
- func (rln *RateLimiterNode) SetLimiters(new *typeutil.ConcurrentMap[internalpb.RateType, *ratelimitutil.Limiter])
- func (rln *RateLimiterNode) SetQuotaStates(new *typeutil.ConcurrentMap[milvuspb.QuotaState, commonpb.ErrorCode])
- type RateLimiterTree
- func (m *RateLimiterTree) ClearInvalidLimiterNode(req *proxypb.LimiterNode)
- func (m *RateLimiterTree) GetCollectionLimiters(dbID, collectionID int64) *RateLimiterNode
- func (m *RateLimiterTree) GetDatabaseLimiters(dbID int64) *RateLimiterNode
- func (m *RateLimiterTree) GetOrCreateCollectionLimiters(dbID, collectionID int64, newDBRateLimiter func() *RateLimiterNode, ...) *RateLimiterNode
- func (m *RateLimiterTree) GetOrCreateDatabaseLimiters(dbID int64, newDBRateLimiter func() *RateLimiterNode) *RateLimiterNode
- func (m *RateLimiterTree) GetOrCreatePartitionLimiters(dbID int64, collectionID int64, partitionID int64, ...) *RateLimiterNode
- func (m *RateLimiterTree) GetPartitionLimiters(dbID, collectionID, partitionID int64) *RateLimiterNode
- func (m *RateLimiterTree) GetRootLimiters() *RateLimiterNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TraverseRateLimiterTree ¶
func TraverseRateLimiterTree(root *RateLimiterNode, fn1 func(internalpb.RateType, *ratelimitutil.Limiter) bool, fn2 func(node *RateLimiterNode, state milvuspb.QuotaState, errCode commonpb.ErrorCode) bool, )
Types ¶
type RateLimiterNode ¶
type RateLimiterNode struct {
// contains filtered or unexported fields
}
func NewRateLimiterNode ¶
func NewRateLimiterNode(level internalpb.RateScope) *RateLimiterNode
func (*RateLimiterNode) AddChild ¶
func (rln *RateLimiterNode) AddChild(key int64, child *RateLimiterNode)
func (*RateLimiterNode) Cancel ¶
func (rln *RateLimiterNode) Cancel(rt internalpb.RateType, n int)
func (*RateLimiterNode) Check ¶
func (rln *RateLimiterNode) Check(rt internalpb.RateType, n int) error
func (*RateLimiterNode) GetChild ¶
func (rln *RateLimiterNode) GetChild(key int64) *RateLimiterNode
func (*RateLimiterNode) GetChildren ¶
func (rln *RateLimiterNode) GetChildren() *typeutil.ConcurrentMap[int64, *RateLimiterNode]
func (*RateLimiterNode) GetID ¶
func (rln *RateLimiterNode) GetID() int64
func (*RateLimiterNode) GetLimiters ¶
func (rln *RateLimiterNode) GetLimiters() *typeutil.ConcurrentMap[internalpb.RateType, *ratelimitutil.Limiter]
func (*RateLimiterNode) GetQuotaExceededError ¶
func (rln *RateLimiterNode) GetQuotaExceededError(rt internalpb.RateType) error
func (*RateLimiterNode) GetQuotaStates ¶
func (rln *RateLimiterNode) GetQuotaStates() *typeutil.ConcurrentMap[milvuspb.QuotaState, commonpb.ErrorCode]
func (*RateLimiterNode) GetRateLimitError ¶
func (rln *RateLimiterNode) GetRateLimitError(rate float64) error
func (*RateLimiterNode) Level ¶
func (rln *RateLimiterNode) Level() internalpb.RateScope
func (*RateLimiterNode) Limit ¶
func (rln *RateLimiterNode) Limit(rt internalpb.RateType, n int) (bool, float64)
Limit returns true, the request will be rejected. Otherwise, the request will pass.
func (*RateLimiterNode) SetLimiters ¶
func (rln *RateLimiterNode) SetLimiters(new *typeutil.ConcurrentMap[internalpb.RateType, *ratelimitutil.Limiter])
func (*RateLimiterNode) SetQuotaStates ¶
func (rln *RateLimiterNode) SetQuotaStates(new *typeutil.ConcurrentMap[milvuspb.QuotaState, commonpb.ErrorCode])
type RateLimiterTree ¶
type RateLimiterTree struct {
// contains filtered or unexported fields
}
RateLimiterTree is implemented based on RateLimiterNode to operate multilevel rate limiters
it contains the following four levels generally:
-> global level -> database level -> collection level -> partition levelearl
func NewRateLimiterTree ¶
func NewRateLimiterTree(root *RateLimiterNode) *RateLimiterTree
NewRateLimiterTree returns a new RateLimiterTree.
func (*RateLimiterTree) ClearInvalidLimiterNode ¶
func (m *RateLimiterTree) ClearInvalidLimiterNode(req *proxypb.LimiterNode)
func (*RateLimiterTree) GetCollectionLimiters ¶
func (m *RateLimiterTree) GetCollectionLimiters(dbID, collectionID int64) *RateLimiterNode
func (*RateLimiterTree) GetDatabaseLimiters ¶
func (m *RateLimiterTree) GetDatabaseLimiters(dbID int64) *RateLimiterNode
func (*RateLimiterTree) GetOrCreateCollectionLimiters ¶
func (m *RateLimiterTree) GetOrCreateCollectionLimiters(dbID, collectionID int64, newDBRateLimiter func() *RateLimiterNode, newCollectionRateLimiter func() *RateLimiterNode, ) *RateLimiterNode
GetOrCreateCollectionLimiters create limiter of collection level for all rate types and rate scopes. create a database rate limiters if db rate limiter does not exist
func (*RateLimiterTree) GetOrCreateDatabaseLimiters ¶
func (m *RateLimiterTree) GetOrCreateDatabaseLimiters(dbID int64, newDBRateLimiter func() *RateLimiterNode) *RateLimiterNode
GetOrCreateDatabaseLimiters get limiter of database level, or create a database limiter if it doesn't exist.
func (*RateLimiterTree) GetOrCreatePartitionLimiters ¶
func (m *RateLimiterTree) GetOrCreatePartitionLimiters(dbID int64, collectionID int64, partitionID int64, newDBRateLimiter func() *RateLimiterNode, newCollectionRateLimiter func() *RateLimiterNode, newPartRateLimiter func() *RateLimiterNode, ) *RateLimiterNode
GetOrCreatePartitionLimiters create limiter of partition level for all rate types and rate scopes. create a database rate limiters if db rate limiter does not exist create a collection rate limiters if collection rate limiter does not exist
func (*RateLimiterTree) GetPartitionLimiters ¶
func (m *RateLimiterTree) GetPartitionLimiters(dbID, collectionID, partitionID int64) *RateLimiterNode
It checks if the rate limiters exist for the database, collection, and partition, returns the corresponding rate limiter tree.
func (*RateLimiterTree) GetRootLimiters ¶
func (m *RateLimiterTree) GetRootLimiters() *RateLimiterNode
GetRootLimiters get root limiters