ratelimit

package
v1.0.95 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ratelimit parses server-provided retry pacing without coupling retry loops to one gateway's header names.

Index

Constants

View Source
const (
	// HeaderLimit is the Lark OpenAPI gateway's request-window quota.
	HeaderLimit = "X-Ogw-Ratelimit-Limit"
	// HeaderReset is the Lark OpenAPI gateway's remaining recovery time in
	// seconds. It takes precedence over the standard Retry-After fallback.
	HeaderReset = "X-Ogw-Ratelimit-Reset"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	RetryAfter time.Duration
	Limit      int64
}

Info is the transport-neutral rate-limit signal extracted from one response.

func ParseHeaders

func ParseHeaders(header http.Header, now time.Time) Info

ParseHeaders reads Lark gateway pacing first, then the standard Retry-After delta-seconds or HTTP-date form. Invalid and non-positive values are ignored.

func ParseStandardHeaders

func ParseStandardHeaders(header http.Header, now time.Time) Info

ParseStandardHeaders reads the standard Retry-After delta-seconds or HTTP-date form.

func (Info) RetryAfterSeconds

func (i Info) RetryAfterSeconds() int

RetryAfterSeconds rounds a positive delay up so serialized retry metadata never asks a caller to retry before the server-provided recovery instant.

Jump to

Keyboard shortcuts

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