ratelimit

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Copyright 2025 National Technology and Engineering Solutions of Sandia SPDX-License-Identifier: BSD-3-Clause

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client applies a Policy before forwarding requests to an HTTP client. It is safe for concurrent use.

func NewClient

func NewClient(httpClient *http.Client, policy Policy, delay func(time.Duration)) *Client

NewClient creates a rate-limited HTTP client. Invalid policies panic because policies are static application configuration rather than user input.

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do waits for both concurrency capacity and a rate-limit token, then performs the request. Waiting honors the request context.

type Policy

type Policy struct {
	RequestsPerSecond float64
	Burst             int
	MaxConcurrent     int
}

Policy configures request starts and in-flight request concurrency.

Jump to

Keyboard shortcuts

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