ratelimit

package
v0.0.0-...-0b85bb3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTooManyRequestsIn24Hours = errors.New("too many Klaytn RPC requests have been sent this 24 hour period")

Functions

func GetUTCMidnightOfDate

func GetUTCMidnightOfDate(date time.Time) time.Time

Rounds the current date and time to midnight of the current day.

Types

type RateLimiter

type RateLimiter interface {
	Wait(ctx context.Context) error
	Start(ctx context.Context, checkpointInterval time.Duration) error
	// contains filtered or unexported methods
}

RateLimiter is the interface one must satisfy to be considered a RateLimiter

func New

func New(maxRequestsPer24Hrs int, maxRequestsPerSecond float64, meshDB *meshdb.MeshDB, aClock clock.Clock) (RateLimiter, error)

New instantiates a new RateLimiter

func NewUnlimited

func NewUnlimited() RateLimiter

NewUnlimited returns a new RateLimiter without any limits. It will always allow requests immediately. It still keeps track of the number of requests that are allowed.

Jump to

Keyboard shortcuts

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