rate

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 rate provides a set of rate-limit proxy and router middlewares using the golang.org/x/time/rate lib.

The rate 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

This section is empty.

Variables

This section is empty.

Functions

func NewLimiterStore

func NewLimiterStore(maxRate float64, capacity int, backend krakendrate.Backend) krakendrate.LimiterStore

NewLimiterStore returns a LimiterStore using the received backend for persistence

func NewMemoryStore

func NewMemoryStore(maxRate float64, capacity int) krakendrate.LimiterStore

NewMemoryStore returns a LimiterStore using the memory backend

Types

type Limiter

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

Limiter is a simple wrapper over the rate.Limiter struct

func NewLimiter

func NewLimiter(maxRate float64, capacity int) Limiter

NewLimiter creates a new Limiter

func (Limiter) Allow

func (l Limiter) Allow() bool

Allow delegates to the internal limiter allow method

Directories

Path Synopsis
Package proxy provides a rate-limit proxy middleware using the golang.org/x/time/rate lib.
Package proxy provides a rate-limit proxy middleware using the golang.org/x/time/rate lib.
Package router provides several rate-limit routers using the golang.org/x/time/rate lib.
Package router provides several rate-limit routers using the golang.org/x/time/rate lib.
gin

Jump to

Keyboard shortcuts

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