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_burst")]
48    pub burst_multiplier: u64,
49}
50
51pub const fn default_oauth_public() -> u64 {
52    10
53}
54pub const fn default_oauth_auth() -> u64 {
55    10
56}
57pub const fn default_contexts() -> u64 {
58    100
59}
60pub const fn default_tasks() -> u64 {
61    50
62}
63pub const fn default_artifacts() -> u64 {
64    50
65}
66pub const fn default_agent_registry() -> u64 {
67    50
68}
69pub const fn default_agents() -> u64 {
70    20
71}
72pub const fn default_mcp_registry() -> u64 {
73    50
74}
75pub const fn default_mcp() -> u64 {
76    200
77}
78pub const fn default_stream() -> u64 {
79    100
80}
81pub const fn default_content() -> u64 {
82    50
83}
84pub const fn default_burst() -> u64 {
85    3
86}
87
88impl Default for RateLimitsConfig {
89    fn default() -> Self {
90        Self {
91            disabled: false,
92            oauth_public_per_second: default_oauth_public(),
93            oauth_auth_per_second: default_oauth_auth(),
94            contexts_per_second: default_contexts(),
95            tasks_per_second: default_tasks(),
96            artifacts_per_second: default_artifacts(),
97            agent_registry_per_second: default_agent_registry(),
98            agents_per_second: default_agents(),
99            mcp_registry_per_second: default_mcp_registry(),
100            mcp_per_second: default_mcp(),
101            stream_per_second: default_stream(),
102            content_per_second: default_content(),
103            burst_multiplier: default_burst(),
104        }
105    }
106}