ratelimit

package
v2.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	// Limit is extracted from x-ratelimit-limit
	Limit int
	// Reset is extracted from x-ratelimit-reset (seconds until reset)
	Reset int
}

Info holds rate limit information extracted from Port HTTP Headers

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func New

func New(opts *Options) *Manager

func (*Manager) Allow

func (m *Manager) Allow() bool

func (*Manager) Close

func (m *Manager) Close()

Close gracefully shuts down the rate limit manager

func (*Manager) GetInfo

func (m *Manager) GetInfo() *Info

func (*Manager) ResponseMiddleware

func (m *Manager) ResponseMiddleware(_ *resty.Client, resp *resty.Response) error

type Options

type Options struct {
	Logger             *slog.Logger
	MinRequestInterval *time.Duration
	Enabled            *bool
	Ctx                context.Context
}

func DefaultOptions

func DefaultOptions() *Options

Jump to

Keyboard shortcuts

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