ratelimit

package
v0.0.58 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRateLimitReached = errors.New("rate limit reached")
)

Functions

func NewRateLimitPolicy

func NewRateLimitPolicy(config *Config) policy.Policy

Types

type CloudProviderRateLimitConfig

type CloudProviderRateLimitConfig struct {
	// The default rate limit config options.
	Config

	// Rate limit config for each clients. Values would override default settings above.
	Entries map[string]*Config `json:",inline" yaml:",inline"`
}

CloudProviderRateLimitConfig indicates the rate limit config for each clients.

func NewCloudProviderRateLimitConfig

func NewCloudProviderRateLimitConfig() *CloudProviderRateLimitConfig

func (*CloudProviderRateLimitConfig) GetRateLimitConfig

func (config *CloudProviderRateLimitConfig) GetRateLimitConfig(clientName string) *Config

GetRateLimitConfig returns the rate limit config for the given client. if the client is not found, the default is returned.

type Config

type Config struct {
	// Enable rate limiting
	CloudProviderRateLimit bool `json:"cloudProviderRateLimit,omitempty" yaml:"cloudProviderRateLimit,omitempty"`
	// Rate limit QPS (Read)
	CloudProviderRateLimitQPS float32 `json:"cloudProviderRateLimitQPS,omitempty" yaml:"cloudProviderRateLimitQPS,omitempty"`
	// Rate limit Bucket Size
	CloudProviderRateLimitBucket int `json:"cloudProviderRateLimitBucket,omitempty" yaml:"cloudProviderRateLimitBucket,omitempty"`
	// Rate limit QPS (Write)
	CloudProviderRateLimitQPSWrite float32 `json:"cloudProviderRateLimitQPSWrite,omitempty" yaml:"cloudProviderRateLimitQPSWrite,omitempty"`
	// Rate limit Bucket Size
	CloudProviderRateLimitBucketWrite int `json:"cloudProviderRateLimitBucketWrite,omitempty" yaml:"cloudProviderRateLimitBucketWrite,omitempty"`
}

Config indicates the rate limit config options.

type Policy

type Policy struct {
	// contains filtered or unexported fields
}

func (Policy) Do

func (f Policy) Do(req *policy.Request) (*http.Response, error)

Directories

Path Synopsis
flowcontrol is imported from https://github.com/kubernetes/client-go/tree/master/util/flowcontrol
flowcontrol is imported from https://github.com/kubernetes/client-go/tree/master/util/flowcontrol

Jump to

Keyboard shortcuts

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