google_api

package
v1.94.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package google_api reads what a Google API says when it refuses a request, and offers the retry policy that follows from it.

The envelope here is the one every Google API answers an error in, rather than any one service's, which is why it sits above them rather than in one of them. (google_ai/gemini's RetryAfterFromResponse reads the same envelope for the delay it advises, and would sit here as well.)

Index

Constants

This section is empty.

Variables

View Source
var RetryResponseChecker = response_checker.New(
	func(response *http.Response, responseBody []byte, err error) bool {
		if response == nil {

			return err != nil
		}

		return response.StatusCode >= http.StatusInternalServerError ||
			IsRateLimited(response, responseBody)
	},
)

RetryResponseChecker is retry_config.DefaultResponseChecker plus the refusal only the body reveals. Wire it into a fetch's retry configuration when talking to a Google API; without it, a caller refused for asking too often gives up as though it had been refused outright.

Functions

func IsRateLimited

func IsRateLimited(response *http.Response, responseBody []byte) bool

IsRateLimited says whether the refusal was for the request having been made too often. Google reports that as 429, or -- and this is the case a status code alone cannot tell apart from a refusal for want of permission -- as 403 with a reason in the body saying so.

Types

This section is empty.

Jump to

Keyboard shortcuts

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