df_hyperliquid_core/live/session/
limits.rs1use crate::live::BadSubscription;
5
6pub const MAX_CONNECTIONS: usize = 10;
8pub const MAX_NEW_CONNECTIONS_PER_MINUTE: usize = 30;
10pub const MAX_SUBSCRIPTIONS: usize = 1_000;
12pub const MAX_USERS: usize = 10;
14pub const MAX_MESSAGES_PER_MINUTE: usize = 2_000;
16pub const MAX_INFLIGHT_POSTS: usize = 100;
18
19#[derive(Debug, Clone, Copy, PartialEq, Eq)]
22pub struct Limits {
23 pub subscriptions: usize,
24 pub users: usize,
25 pub posts: usize,
26}
27
28impl Limits {
29 pub const VENUE: Limits = Limits { subscriptions: MAX_SUBSCRIPTIONS, users: MAX_USERS, posts: MAX_INFLIGHT_POSTS };
30}
31
32impl Default for Limits {
33 fn default() -> Self {
34 Limits::VENUE
35 }
36}
37
38#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
40pub enum Refused {
41 #[error("{limit} subscriptions is the most this session holds; the venue allows an IP 1000")]
42 Subscriptions { limit: usize },
43 #[error("{limit} users is the most this session follows; the venue allows an IP 10")]
44 Users { limit: usize },
45 #[error("{limit} posts are already waiting for an answer; the venue allows an IP 100")]
46 Posts { limit: usize },
47 #[error("the socket is not open, and a post is never held to send later")]
50 Closed,
51 #[error(transparent)]
52 Bad(#[from] BadSubscription),
53}
54
55#[cfg(test)]
56#[path = "tests/limits.rs"]
57mod tests;