Documentation
¶
Overview ¶
Package router provides several rate-limit routers.
The ratelimit package provides an efficient token bucket implementation. See http://en.wikipedia.org/wiki/Token_bucket for more details.
Index ¶
Constants ¶
View Source
const Namespace = "qos/ratelimit/router"
Namespace is the key to use to store and access the custom config data for the router
Variables ¶
View Source
var ( ErrNoExtraCfg = errors.New("no extra config") ErrWrongExtraCfg = errors.New("wrong extra config") )
View Source
var ZeroCfg = Config{}
ZeroCfg is the zero value for the Config struct
Functions ¶
func StoreFromCfg ¶
func StoreFromCfg(cfg Config) krakendrate.LimiterStore
Types ¶
type Config ¶
type Config struct {
MaxRate float64 `json:"max_rate"`
Capacity uint64 `json:"capacity"`
Strategy string `json:"strategy"`
ClientMaxRate float64 `json:"client_max_rate"`
ClientCapacity uint64 `json:"client_capacity"`
Key string `json:"key"`
TTL time.Duration `json:"every"`
NumShards uint64 `json:"num_shards"`
CleanUpPeriod time.Duration `json:"cleanup_period"`
CleanUpThreads uint64 `json:"cleanup_threads"`
}
Config is the custom config struct containing the params for the router middlewares
func ConfigGetter ¶
func ConfigGetter(e config.ExtraConfig) (Config, error)
ConfigGetter parses the extra config for the rate adapter and returns a ZeroCfg and an error if something goes wrong.
Click to show internal directories.
Click to hide internal directories.