systemprompt_models/config/
rate_limits.rs1use crate::profile::RateLimitsConfig;
7
8#[derive(Debug, Clone, Copy)]
9pub struct RateLimitConfig {
10 pub oauth_public_per_second: u64,
11 pub oauth_auth_per_second: u64,
12 pub contexts_per_second: u64,
13 pub tasks_per_second: u64,
14 pub artifacts_per_second: u64,
15 pub agent_registry_per_second: u64,
16 pub agents_per_second: u64,
17 pub mcp_registry_per_second: u64,
18 pub mcp_per_second: u64,
19 pub stream_per_second: u64,
20 pub content_per_second: u64,
21 pub burst_multiplier: u64,
22 pub disabled: bool,
23}
24
25impl Default for RateLimitConfig {
26 fn default() -> Self {
27 Self {
28 oauth_public_per_second: 10,
29 oauth_auth_per_second: 10,
30 contexts_per_second: 100,
31 tasks_per_second: 50,
32 artifacts_per_second: 50,
33 agent_registry_per_second: 50,
34 agents_per_second: 20,
35 mcp_registry_per_second: 50,
36 mcp_per_second: 200,
37 stream_per_second: 100,
38 content_per_second: 50,
39 burst_multiplier: 3,
40 disabled: false,
41 }
42 }
43}
44
45impl RateLimitConfig {
46 pub fn production() -> Self {
47 Self::default()
48 }
49
50 pub const fn testing() -> Self {
51 Self {
52 oauth_public_per_second: 10000,
53 oauth_auth_per_second: 10000,
54 contexts_per_second: 10000,
55 tasks_per_second: 10000,
56 artifacts_per_second: 10000,
57 agent_registry_per_second: 10000,
58 agents_per_second: 10000,
59 mcp_registry_per_second: 10000,
60 mcp_per_second: 10000,
61 stream_per_second: 10000,
62 content_per_second: 10000,
63 burst_multiplier: 100,
64 disabled: false,
65 }
66 }
67
68 pub const fn disabled() -> Self {
69 let mut config = Self::testing();
70 config.disabled = true;
71 config
72 }
73}
74
75impl From<&RateLimitsConfig> for RateLimitConfig {
76 fn from(config: &RateLimitsConfig) -> Self {
77 Self {
78 oauth_public_per_second: config.oauth_public_per_second,
79 oauth_auth_per_second: config.oauth_auth_per_second,
80 contexts_per_second: config.contexts_per_second,
81 tasks_per_second: config.tasks_per_second,
82 artifacts_per_second: config.artifacts_per_second,
83 agent_registry_per_second: config.agent_registry_per_second,
84 agents_per_second: config.agents_per_second,
85 mcp_registry_per_second: config.mcp_registry_per_second,
86 mcp_per_second: config.mcp_per_second,
87 stream_per_second: config.stream_per_second,
88 content_per_second: config.content_per_second,
89 burst_multiplier: config.burst_multiplier,
90 disabled: config.disabled,
91 }
92 }
93}