Skip to main content

systemprompt_models/profile/
rate_limits.rs

1//! Rate limits configuration.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Copy, Serialize, Deserialize, schemars::JsonSchema)]
9#[serde(deny_unknown_fields)]
10pub struct RateLimitsConfig {
11    #[serde(default)]
12    pub disabled: bool,
13
14    #[serde(default = "default_oauth_public")]
15    pub oauth_public_per_second: u64,
16
17    #[serde(default = "default_oauth_auth")]
18    pub oauth_auth_per_second: u64,
19
20    #[serde(default = "default_contexts")]
21    pub contexts_per_second: u64,
22
23    #[serde(default = "default_tasks")]
24    pub tasks_per_second: u64,
25
26    #[serde(default = "default_artifacts")]
27    pub artifacts_per_second: u64,
28
29    #[serde(default = "default_agent_registry")]
30    pub agent_registry_per_second: u64,
31
32    #[serde(default = "default_agents")]
33    pub agents_per_second: u64,
34
35    #[serde(default = "default_mcp_registry")]
36    pub mcp_registry_per_second: u64,
37
38    #[serde(default = "default_mcp")]
39    pub mcp_per_second: u64,
40
41    #[serde(default = "default_stream")]
42    pub stream_per_second: u64,
43
44    #[serde(default = "default_content")]
45    pub content_per_second: u64,
46
47    #[serde(default = "default_gateway")]
48    pub gateway_per_second: u64,
49
50    #[serde(default = "default_burst")]
51    pub burst_multiplier: u64,
52}
53
54pub const fn default_oauth_public() -> u64 {
55    10
56}
57pub const fn default_oauth_auth() -> u64 {
58    10
59}
60pub const fn default_contexts() -> u64 {
61    100
62}
63pub const fn default_tasks() -> u64 {
64    50
65}
66pub const fn default_artifacts() -> u64 {
67    50
68}
69pub const fn default_agent_registry() -> u64 {
70    50
71}
72pub const fn default_agents() -> u64 {
73    20
74}
75pub const fn default_mcp_registry() -> u64 {
76    50
77}
78pub const fn default_mcp() -> u64 {
79    200
80}
81pub const fn default_stream() -> u64 {
82    100
83}
84pub const fn default_content() -> u64 {
85    50
86}
87pub const fn default_gateway() -> u64 {
88    100
89}
90pub const fn default_burst() -> u64 {
91    3
92}
93
94impl Default for RateLimitsConfig {
95    fn default() -> Self {
96        Self {
97            disabled: false,
98            oauth_public_per_second: default_oauth_public(),
99            oauth_auth_per_second: default_oauth_auth(),
100            contexts_per_second: default_contexts(),
101            tasks_per_second: default_tasks(),
102            artifacts_per_second: default_artifacts(),
103            agent_registry_per_second: default_agent_registry(),
104            agents_per_second: default_agents(),
105            mcp_registry_per_second: default_mcp_registry(),
106            mcp_per_second: default_mcp(),
107            stream_per_second: default_stream(),
108            content_per_second: default_content(),
109            gateway_per_second: default_gateway(),
110            burst_multiplier: default_burst(),
111        }
112    }
113}