ratelimitutil

package
v0.0.0-...-34e0b2d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

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 (*RateLimiterNode) GetID

func (rln *RateLimiterNode) GetID() int64

func (*RateLimiterNode) GetLimiters

func (*RateLimiterNode) GetQuotaExceededError

func (rln *RateLimiterNode) GetQuotaExceededError(rt internalpb.RateType) error

func (*RateLimiterNode) GetQuotaStates

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 (*RateLimiterNode) SetQuotaStates

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL