sleepForRetryAfter() — fiber Function Reference
Architecture documentation for the sleepForRetryAfter() function in limiter_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD a70ffa85_f38b_cd52_97fa_bce8a29e5dab["sleepForRetryAfter()"] 0509da96_221e_0d0d_fe2e_f2e2e3695b6f["limiter_test.go"] a70ffa85_f38b_cd52_97fa_bce8a29e5dab -->|defined in| 0509da96_221e_0d0d_fe2e_f2e2e3695b6f 2b13e59a_e38c_ab70_c154_7c2edddd65d9["Test_Limiter_Sliding_ExpirationFuncOverridesStaticExpiration()"] 2b13e59a_e38c_ab70_c154_7c2edddd65d9 -->|calls| a70ffa85_f38b_cd52_97fa_bce8a29e5dab 73cf8b78_d6ee_02d5_912f_a9cd76f7434a["Test_Limiter_Sliding_Window_No_Skip_Choices()"] 73cf8b78_d6ee_02d5_912f_a9cd76f7434a -->|calls| a70ffa85_f38b_cd52_97fa_bce8a29e5dab a569f03c_72e7_e1b2_838e_46d2825bb8d5["Test_Limiter_Sliding_Window_Custom_Storage_No_Skip_Choices()"] a569f03c_72e7_e1b2_838e_46d2825bb8d5 -->|calls| a70ffa85_f38b_cd52_97fa_bce8a29e5dab c03663f5_cb7e_df76_4979_e40b2bafe784["Test_Limiter_Sliding_Window_Skip_Failed_Requests()"] c03663f5_cb7e_df76_4979_e40b2bafe784 -->|calls| a70ffa85_f38b_cd52_97fa_bce8a29e5dab 3f16f39f_6975_5199_3b86_7376554bc33e["Test_Limiter_Sliding_Window_Custom_Storage_Skip_Failed_Requests()"] 3f16f39f_6975_5199_3b86_7376554bc33e -->|calls| a70ffa85_f38b_cd52_97fa_bce8a29e5dab 948eb014_3972_7a2a_6257_14b05674e0f6["Test_Limiter_Sliding_Window_Skip_Successful_Requests()"] 948eb014_3972_7a2a_6257_14b05674e0f6 -->|calls| a70ffa85_f38b_cd52_97fa_bce8a29e5dab a394c015_06f8_0692_8697_fc482722c969["Test_Limiter_Sliding_Window_Custom_Storage_Skip_Successful_Requests()"] a394c015_06f8_0692_8697_fc482722c969 -->|calls| a70ffa85_f38b_cd52_97fa_bce8a29e5dab style a70ffa85_f38b_cd52_97fa_bce8a29e5dab fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/limiter/limiter_test.go lines 72–94
func sleepForRetryAfter(t *testing.T, resp *http.Response) {
t.Helper()
retryAfter := resp.Header.Get(fiber.HeaderRetryAfter)
if retryAfter == "" {
time.Sleep(500 * time.Millisecond)
return
}
seconds, err := strconv.Atoi(retryAfter)
require.NoError(t, err)
delay := time.Duration(seconds) * time.Second
// Sliding window needs roughly 2x the reported delay for the previous window to expire.
if doubled := 2 * delay; doubled > delay {
delay = doubled
}
if minDelay := 4 * time.Second; delay < minDelay {
delay = minDelay
}
time.Sleep(delay + 500*time.Millisecond)
}
Domain
Subdomains
Defined In
Called By
- Test_Limiter_Sliding_ExpirationFuncOverridesStaticExpiration()
- Test_Limiter_Sliding_Window_Custom_Storage_No_Skip_Choices()
- Test_Limiter_Sliding_Window_Custom_Storage_Skip_Failed_Requests()
- Test_Limiter_Sliding_Window_Custom_Storage_Skip_Successful_Requests()
- Test_Limiter_Sliding_Window_No_Skip_Choices()
- Test_Limiter_Sliding_Window_Skip_Failed_Requests()
- Test_Limiter_Sliding_Window_Skip_Successful_Requests()
Source
Frequently Asked Questions
What does sleepForRetryAfter() do?
sleepForRetryAfter() is a function in the fiber codebase, defined in middleware/limiter/limiter_test.go.
Where is sleepForRetryAfter() defined?
sleepForRetryAfter() is defined in middleware/limiter/limiter_test.go at line 72.
What calls sleepForRetryAfter()?
sleepForRetryAfter() is called by 7 function(s): Test_Limiter_Sliding_ExpirationFuncOverridesStaticExpiration, Test_Limiter_Sliding_Window_Custom_Storage_No_Skip_Choices, Test_Limiter_Sliding_Window_Custom_Storage_Skip_Failed_Requests, Test_Limiter_Sliding_Window_Custom_Storage_Skip_Successful_Requests, Test_Limiter_Sliding_Window_No_Skip_Choices, Test_Limiter_Sliding_Window_Skip_Failed_Requests, Test_Limiter_Sliding_Window_Skip_Successful_Requests.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free