MCPcopy Index your code
hub / github.com/coder/coder / checkRateLimitError

Function checkRateLimitError

coderd/externalauth/gitprovider/gitprovider.go:232–247  ·  view source on GitHub ↗

checkRateLimitError returns a *RateLimitError when resp indicates a rate limit (HTTP 403 or 429) with recognizable retry headers; otherwise nil. A nil resp returns nil.

(resp *http.Response, clk quartz.Clock, resetHeader string)

Source from the content-addressed store, hash-verified

230// rate limit (HTTP 403 or 429) with recognizable retry headers;
231// otherwise nil. A nil resp returns nil.
232func checkRateLimitError(resp *http.Response, clk quartz.Clock, resetHeader string) error {
233 if resp == nil {
234 return nil
235 }
236 if resp.StatusCode != http.StatusForbidden && resp.StatusCode != http.StatusTooManyRequests {
237 return nil
238 }
239 if clk == nil {
240 clk = quartz.NewReal()
241 }
242 retryAfter := parseRetryAfter(resp.Header, resetHeader, clk)
243 if retryAfter <= 0 {
244 return nil
245 }
246 return &RateLimitError{RetryAfter: clk.Now().Add(retryAfter + RateLimitPadding)}
247}
248
249// countDiffLines counts added and deleted lines in a unified diff. It excludes
250// file header lines such as +++ b/file and --- a/file.

Callers 5

decodeJSONMethod · 0.85
fetchDiffMethod · 0.85
FetchPullRequestDiffMethod · 0.85
FetchBranchDiffMethod · 0.85
wrapErrorMethod · 0.85

Calls 2

parseRetryAfterFunction · 0.85
AddMethod · 0.65

Tested by

no test coverage detected