ratelimitplugin

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLimitPlugin

type RateLimitPlugin struct {
	RateLimit *ratelimit.RateLimiter
}

func NewRateLimitPlugin

func NewRateLimitPlugin(rateLimitPerSecond int,
	initializeWithoutSlack bool) *RateLimitPlugin

NewHystrixGoPlugin creates a hystrixgo plugin struct object this plugin implements the CircuitBreakerIFace interface

rateLimitPerSecond = number of actions per second allowed, 0 for no rate limit control initializeWithoutSlack = true: no slack (disallow initial spike consideration)

func (*RateLimitPlugin) Take

func (p *RateLimitPlugin) Take() time.Time

Take is called by each method needing rate limit applied

based on rate limit per second setting, given amount of time is slept before process continues

for example, 1 second rate limit 100 = 100 milliseconds per call, this causes each call to Take sleep for 100 milliseconds before continuing

returns time when Take took place

Jump to

Keyboard shortcuts

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