ratelimit

package
v0.255.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rate

type Rate struct {
	// N represents the number of tokens to add or leak per the specified duration.
	N int
	// Per defines the duration over which N tokens are added or leaked (e.g., 1 second or 1 minute).
	Per time.Duration
}

func (Rate) IsZero

func (r Rate) IsZero() bool

func (Rate) Pace

func (r Rate) Pace() time.Duration

func (Rate) String

func (r Rate) String() string

type SlidingWindow

type SlidingWindow struct {
	Rate Rate
	// contains filtered or unexported fields
}
Example
package main

import (
	"time"

	"go.llib.dev/frameless/pkg/ratelimit"
)

func main() {
	_ = ratelimit.SlidingWindow{Rate: ratelimit.Rate{N: 100, Per: time.Minute}}
}

func (*SlidingWindow) Throttle

func (rl *SlidingWindow) Throttle(ctx context.Context) error

type Throttling

type Throttling interface {
	Throttle(context.Context) error
}

Jump to

Keyboard shortcuts

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