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 ¶
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 ¶
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.