githublimit

package
v3.0.0-dev.5 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package githublimit reads GitHub's rate-limit answers, for every package that reaches GitHub's API: the github client and the creds package's App mint (https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DocumentLimited

func DocumentLimited(status int, header http.Header, said bool) (limited, secondaryLimit bool)

DocumentLimited is Read's Limited and Secondary for a document answer carrying errors and no data, which GitHub answers a limit with at 200 too: a primary limit with the remaining figure at zero, a secondary limit with its message (https://docs.github.com/en/graphql/overview/rate-limits-and-query-limits-for-the-graphql-api#exceeding-the-rate-limit).

func Message

func Message(body []byte) string

Message is the message member of a GitHub refusal's JSON body, empty where the body carries none or is not JSON. It is GitHub's text, so a caller quotes it before showing it.

func Pool

func Pool(header http.Header) (name string, limit int)

Pool names the rate-limit pool an answer drew on, core for REST and graphql for documents among them, and that pool's whole limit, zero where the answer states none (https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api#checking-the-status-of-your-rate-limit).

func SecondaryMessage

func SecondaryMessage(message string) bool

SecondaryMessage reports whether a message is the one GitHub answers a secondary limit with: it carries [secondaryTerm] in any case.

func Signal

func Signal(header http.Header) (remaining int, reset time.Time, ok bool)

Signal reads the budget signal riding every answer on both of GitHub's surfaces: the remaining units of the pool the answer drew on, ok false where none is readable, and the instant that window renews, as epoch seconds, whatever ok reads, the zero time where the answer carries no reset. It is read from the answer and never from the rate-limit endpoint, which is measured to report a full pool with a fresh window while the same credential's document budget was demonstrably drawn down.

Types

type Limit

type Limit struct {
	Reset      time.Time
	Pool       string
	RetryAfter time.Duration
	Remaining  int
	Limit      int
	Limited    bool
	Secondary  bool
}

Limit is one answer's rate-limit facts, as github.RateLimit documents them: github.ReadLimit converts one into the other, so their fields stay alike.

func Read

func Read(status int, header http.Header, body []byte) Limit

Read reads one answer's rate-limit facts from its status, header and body, the body's JSON message member being the one place the secondary-limit message is read.

Jump to

Keyboard shortcuts

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