TestNew | Creates middleware with limit of 2 and sends 5 concurrent requests | Max concurrent requests never exceeds the configured limit of 2 |
TestNew_RejectsOverCapacity | Sends 3 concurrent requests with limit of 1 | Some requests are rejected with 503 Service Unavailable status |
TestWithOptions_ErrorHandler | Uses custom error handler with Max: 0 | Custom error handler is invoked, returns 429 with JSON error message |
TestBlocking | Uses Blocking variant with limit of 2 and 5 concurrent requests | All requests eventually succeed (200 OK), max concurrent never exceeds 2 |
TestRetryAfterHeader | Sends request with Max: 0 (immediate rejection) | Response includes “Retry-After: 1” header |
TestWithContext | Uses WithContext variant with limit of 2 and 5 concurrent requests | Max concurrent requests never exceeds limit of 2 |
TestWithContext_ContextCancellation | Tests context cancellation with WithContext variant | First request blocks, completes when channel is closed |
TestWithOptions_NegativeMax | Configures middleware with Max: -1 | All requests rejected with 503 Service Unavailable |
TestWithOptions_ErrorHandlerAtCapacity | Custom error handler with Max: 1, sends 2 concurrent requests | Second request triggers custom error handler, returns 429 status |