ratelimit

package
v0.0.0-...-01d7cdc Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package ratelimit implements rate limiter.

Index

Constants

View Source
const OkMessage = "OK"

OkMessage is the message returned when it's ok to request.

Variables

View Source
var (

	// RootContextCanceled is returned when the parent context was canceled.
	RootContextCanceled = "root " + canceledMsg
)

Functions

This section is empty.

Types

type RequestLimiter

type RequestLimiter interface {
	// Check returns true if it's ok to request.
	Check() (msg string, ok bool)
	// Advance must be called after Check.
	Advance()
	// SetInterval updates the interval.
	SetInterval(interval time.Duration)
}

RequestLimiter limits requests.

func NewRequestLimiter

func NewRequestLimiter(rootCtx context.Context, interval time.Duration) RequestLimiter

NewRequestLimiter returns a new RequestLimiter.

Jump to

Keyboard shortcuts

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