Documentation

Overview

Package ratelimit implements rate limiter.

Index

Constants

const OkMessage = "OK"

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


Variables

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.