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 gateway_per_second: u64,
22 pub burst_multiplier: u64,
23 pub disabled: bool,
24}
25
26impl Default for RateLimitConfig {
27 fn default() -> Self {
28 Self {
29 oauth_public_per_second: 10,
30 oauth_auth_per_second: 10,
31 contexts_per_second: 100,
32 tasks_per_second: 50,
33 artifacts_per_second: 50,
34 agent_registry_per_second: 50,
35 agents_per_second: 20,
36 mcp_registry_per_second: 50,
37 mcp_per_second: 200,
38 stream_per_second: 100,
39 content_per_second: 50,
40 gateway_per_second: 100,
41 burst_multiplier: 3,
42 disabled: false,
43 }
44 }
45}
46
47impl RateLimitConfig {
48 pub fn production() -> Self {
49 Self::default()
50 }
51
52 pub const fn testing() -> Self {
53 Self {
54 oauth_public_per_second: 10000,
55 oauth_auth_per_second: 10000,
56 contexts_per_second: 10000,
57 tasks_per_second: 10000,
58 artifacts_per_second: 10000,
59 agent_registry_per_second: 10000,
60 agents_per_second: 10000,
61 mcp_registry_per_second: 10000,
62 mcp_per_second: 10000,
63 stream_per_second: 10000,
64 content_per_second: 10000,
65 gateway_per_second: 10000,
66 burst_multiplier: 100,
67 disabled: false,
68 }
69 }
70
71 pub const fn disabled() -> Self {
72 let mut config = Self::testing();
73 config.disabled = true;
74 config
75 }
76}
77
78impl From<&RateLimitsConfig> for RateLimitConfig {
79 fn from(config: &RateLimitsConfig) -> Self {
80 Self {
81 oauth_public_per_second: config.oauth_public_per_second,
82 oauth_auth_per_second: config.oauth_auth_per_second,
83 contexts_per_second: config.contexts_per_second,
84 tasks_per_second: config.tasks_per_second,
85 artifacts_per_second: config.artifacts_per_second,
86 agent_registry_per_second: config.agent_registry_per_second,
87 agents_per_second: config.agents_per_second,
88 mcp_registry_per_second: config.mcp_registry_per_second,
89 mcp_per_second: config.mcp_per_second,
90 stream_per_second: config.stream_per_second,
91 content_per_second: config.content_per_second,
92 gateway_per_second: config.gateway_per_second,
93 burst_multiplier: config.burst_multiplier,
94 disabled: config.disabled,
95 }
96 }
97}