build.utils.misc.throttling.rate_limit()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 18
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 18
rs 10
c 0
b 0
f 0
cc 2
nop 2
1
# -*- coding: utf-8 -*-
2
3
4
"""
5
6
7
    Created on 10.09.2021
8
9
    @author: Nikita
10
11
12
"""
13
14
15
def rate_limit(limit: int, key=None):
16
17
    """
18
19
    Decorator for configuring rate limit and key in different functions.
20
21
    """
22
23
    def decorator(func):
24
25
        setattr(func, 'throttling_rate_limit', limit)
26
27
        if key:
28
            setattr(func, 'throttling_key', key)
29
30
        return func
31
32
    return decorator
33