ai_lib/rate_limiter/
config.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct RateLimiterConfig {
8 pub requests_per_second: u64,
10 pub burst_capacity: u64,
12 pub adaptive: bool,
14 pub initial_rate: Option<u64>,
16}
17
18impl Default for RateLimiterConfig {
19 fn default() -> Self {
20 Self {
21 requests_per_second: 10,
22 burst_capacity: 20,
23 adaptive: false,
24 initial_rate: None,
25 }
26 }
27}
28
29impl RateLimiterConfig {
30 pub fn production() -> Self {
32 Self {
33 requests_per_second: 5,
34 burst_capacity: 10,
35 adaptive: true,
36 initial_rate: Some(5),
37 }
38 }
39
40 pub fn development() -> Self {
42 Self {
43 requests_per_second: 20,
44 burst_capacity: 50,
45 adaptive: false,
46 initial_rate: None,
47 }
48 }
49
50 pub fn conservative() -> Self {
52 Self {
53 requests_per_second: 2,
54 burst_capacity: 5,
55 adaptive: true,
56 initial_rate: Some(1),
57 }
58 }
59}