router

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package router provides several rate-limit routers using the golang.org/x/time/rate lib.

Sample endpoint extra config

...
"extra_config": {
	...
	"github.com/devopsfaith/krakend-ratelimit/rate/router": {
		"maxRate": 2000,
		"strategy": "header",
		"clientMaxRate": 100,
		"key": "X-Private-Token",
	},
	...
},
...

The ratelimit package provides an efficient token bucket implementation. See https://golang.org/x/time/rate and http://en.wikipedia.org/wiki/Token_bucket for more details.

Index

Constants

View Source
const Namespace = "github.com/alnyli07/krakend-ratelimit/rate/router"

Namespace is the key to use to store and access the custom config data for the router

Variables

View Source
var ZeroCfg = Config{}

ZeroCfg is the zero value for the Config struct

Functions

func ConfigGetter

func ConfigGetter(e config.ExtraConfig) interface{}

ConfigGetter implements the config.ConfigGetter interface. It parses the extra config for the rate adapter and returns a ZeroCfg if something goes wrong.

Types

type Config

type Config struct {
	MaxRate       int
	Strategy      string
	ClientMaxRate int
	Key           string
}

Config is the custom config struct containing the params for the router middlewares

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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