router

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package router provides several rate-limit routers using the github.com/juju/ratelimit lib.

Sample endpoint extra config

...
"extra_config": {
	...
	"github.com/devopsfaith/krakend-ratelimit/juju/router": {
		"max_rate": 2000,
		"strategy": "header",
		"client_max_rate": 100,
		"key": "X-Private-Token",
	},
	...
},
...

The ratelimit package provides an efficient token bucket implementation. See https://github.com/juju/ratelimit and http://en.wikipedia.org/wiki/Token_bucket for more details.

Index

Constants

View Source
const Namespace = "github.com/devopsfaith/krakend-ratelimit/juju/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

This section is empty.

Types

type Config

type Config struct {
	MaxRate        float64
	Capacity       int64
	Strategy       string
	ClientMaxRate  float64
	ClientCapacity int64
	Key            string
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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