slack_morphism/ratectl/
team_limits.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use crate::ratectl::*;
use std::collections::HashMap;
use std::time::Instant;

#[derive(Debug)]
pub struct SlackTeamLimits {
    pub team_limit_counter: Option<ThrottlingCounter>,
    pub tier_limits: HashMap<SlackApiMethodRateTier, ThrottlingCounter>,
    pub special_limits: HashMap<SlackApiRateControlSpecialLimitKey, ThrottlingCounter>,
    pub updated: Instant,
}

impl SlackTeamLimits {
    pub fn new(rate_control_config: &SlackApiRateControlConfig) -> Self {
        Self {
            team_limit_counter: rate_control_config
                .team_max_rate_limit
                .clone()
                .map(|rl| rl.to_throttling_counter()),
            tier_limits: HashMap::new(),
            special_limits: HashMap::new(),
            updated: Instant::now(),
        }
    }
}