| Conditions | 2 |
| Total Lines | 18 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | # -*- coding: utf-8 -*- |
||
| 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 |