ratelimit

package
v1.0.89 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 5 Imported by: 0

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