slack_morphism/ratectl/
team_limits.rs

1use crate::ratectl::*;
2use std::collections::HashMap;
3use std::time::Instant;
4
5#[derive(Debug)]
6pub struct SlackTeamLimits {
7    pub team_limit_counter: Option<ThrottlingCounter>,
8    pub tier_limits: HashMap<SlackApiMethodRateTier, ThrottlingCounter>,
9    pub special_limits: HashMap<SlackApiRateControlSpecialLimitKey, ThrottlingCounter>,
10    pub updated: Instant,
11}
12
13impl SlackTeamLimits {
14    pub fn new(rate_control_config: &SlackApiRateControlConfig) -> Self {
15        Self {
16            team_limit_counter: rate_control_config
17                .team_max_rate_limit
18                .clone()
19                .map(|rl| rl.to_throttling_counter()),
20            tier_limits: HashMap::new(),
21            special_limits: HashMap::new(),
22            updated: Instant::now(),
23        }
24    }
25}