juju

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package juju provides a set of rate-limit proxy and router middlewares using the github.com/juju/ratelimit lib.

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

This section is empty.

Variables

This section is empty.

Functions

func NewLimiterStore

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

NewLimiterStore returns a LimiterStore using the received backend for persistence

func NewMemoryStore

func NewMemoryStore(maxRate float64, capacity int64) 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 ratelimit.Bucket struct

func NewLimiter

func NewLimiter(maxRate float64, capacity int64) Limiter

NewLimiter creates a new Limiter

func (Limiter) Allow

func (l Limiter) Allow() bool

Allow checks if its possible to extract 1 token from the bucket

Directories

Path Synopsis
Package proxy provides a rate-limit proxy middleware using the github.com/juju/ratelimit lib.
Package proxy provides a rate-limit proxy middleware using the github.com/juju/ratelimit lib.
Package router provides several rate-limit routers using the github.com/juju/ratelimit lib.
Package router provides several rate-limit routers using the github.com/juju/ratelimit lib.
gin
mux

Jump to

Keyboard shortcuts

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