Repository navigation
v0.30.1
Retries rate-limited HTTP calls, and decodes error codes that are strings.
Added
http.CodeGatewayRateLimited(459101): the code that the unified gateway returns when it rejects a request because of a rate limit.http.ApiError.RetryAfter: how long the server asked the client to wait, read from theRetry-Afterresponse header. It is0when the response has no such header.
Changed
http.Client.Callretries rate-limited requests (#137). A request is rate-limited when the response has HTTP status 429 or code459101.Callretries such a request up to 5 times. The first wait is 100ms, and each next wait is double the one before it.- If the response has a
Retry-Afterheader,Callwaits for that time instead. The header can be a number of seconds, an HTTP date, or a Go duration such as1.5s. - If the
Retry-Aftertime is more than 10s,Callreturns the error and does not retry. Callretries every HTTP method, including POST. This is safe because the gateway rejects a rate-limited request before it sends the request on to a service.CallSSEdoes not retry.
- If the response has a
- A non-200 response with a JSON body that cannot be decoded now returns an
*http.ApiError. The error keeps the HTTP status and the trace ID, and its message is the raw body. Before this change,Callreturned a JSON decode error.
Fixed
- An error code that is a string no longer causes a decode failure (#137). An example is
{"code":"459101","message":"request too many"}. A code that is a number or a numeric string becomes anint. Any other value becomes500.
Full changelog: v0.30.0...v0.30.1