Check if a request should be allowed
(&self, client_ip: Option<IpAddr>)
| 346 | |
| 347 | /// Check if a request should be allowed |
| 348 | pub fn check_request(&self, client_ip: Option<IpAddr>) -> Result<(), RateLimitError> { |
| 349 | // First check circuit breaker |
| 350 | if self.circuit_config.enabled { |
| 351 | self.check_circuit_breaker()?; |
| 352 | } |
| 353 | |
| 354 | // Then check rate limits |
| 355 | self.check_rate_limits(client_ip)?; |
| 356 | |
| 357 | // Record successful request for circuit breaker |
| 358 | if self.circuit_config.enabled { |
| 359 | self.record_success(); |
| 360 | } |
| 361 | |
| 362 | // Cleanup old entries periodically |
| 363 | self.maybe_cleanup(); |
| 364 | |
| 365 | Ok(()) |
| 366 | } |
| 367 | |
| 368 | /// Record a request failure for circuit breaker |
| 369 | pub fn record_failure(&self) { |
no test coverage detected