router

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2019 License: Apache-2.0 Imports: 2 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/rate/router": {
		"maxRate": 2000,
		"strategy": "header",
		"clientMaxRate": 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 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       int64
	Strategy      string
	ClientMaxRate int64
	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