githubtest

package
v3.0.0-dev.4 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: 5 Imported by: 0

Documentation

Overview

Package githubtest is GitHub's rate-limit answers as cases a GitHub classifier runs: what github.ReadLimit, or the github client's GraphQL document path, reads from each, the kind the github client's error answers it with, and the effect a classifier answers its gate with (https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api, https://docs.github.com/en/graphql/overview/rate-limits-and-query-limits-for-the-graphql-api).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Effect

type Effect struct {
	// Reset is the end the classifier passes where Limited: Read.Reset where
	// Read.Remaining is 0, else the zero time.
	Reset time.Time
	// Pool is the pool held where Limited, empty for the whole connection: a
	// secondary limit holds every pool, whatever Read.Pool names.
	Pool string
	// RetryAfter is Read.RetryAfter where Limited, uncapped.
	RetryAfter time.Duration
	// Limited reports that the gate holds. Holding with a zero RetryAfter and
	// a zero Reset is the back-off curve from one minute.
	Limited bool
	// Refused reports that the credential was refused: a step toward a disable.
	Refused bool
	// Attributed reports a Refused credential's own refusal: disabled at once.
	Attributed bool
}

Effect is a GitHub classifier's whole answer for one case, in forgeapi's terms. The zero Effect is OK: no hold and no step toward a disable.

type LimitCase

type LimitCase struct {
	// Header is the full X-RateLimit-* set a real answer carries (limit,
	// remaining, used, reset and resource), with Retry-After where the case
	// has one.
	Header http.Header
	// Body is GitHub's own JSON body, a REST error's or a document's envelope,
	// except the case whose body is a proxy's page.
	Body []byte
	// Name names the case, fit for a subtest name.
	Name string
	// Effect is what a GitHub classifier answers its gate with for the answer.
	Effect Effect
	// Read is what [github.ReadLimit] answers; on a Document case, the facts the
	// document path puts on the client's *forgeapi.Error, since ReadLimit reads
	// REST answers alone.
	Read github.RateLimit
	// Status is the answer's HTTP status.
	Status int
	// Kind is what the github client's *forgeapi.Error answers.
	Kind forgeapi.ErrorKind
	// Document reports an answer to a GraphQL document: Body is its envelope.
	Document bool
}

LimitCase is one answer GitHub gives and what each reader makes of it.

func LimitCases

func LimitCases(now time.Time) []LimitCase

LimitCases answers GitHub's rate-limit answers as of now, each reset whole epoch seconds after now. On REST, at the core pool: a secondary limit by its Retry-After, by its message at remaining 0 and alone at remaining 4000, the retired abuse-detection wording with Retry-After, a primary limit, any other 429, a 401, a 403 that is no limit, a 404, a proxy's non-JSON page carrying the term, and a JSON 403 carrying it only in errors[].message with no top-level message, each of the last four no limit. On a document, at the graphql pool: a primary limit at 200, secondary limits at 200 by Retry-After and by the message, at 403 by the message, and at 403 and 429 at remaining 0 with the message in the envelope's errors.

Jump to

Keyboard shortcuts

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