slackapi / slackapi/python-slack-sdk
Add smart Rate Limiter
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 4k
- Fork
- 857
- Merge trung bình
- 22 giờ 21 phút
- Pull request đã merge (30 ngày)
- 16
Mô tả
Now that we have a built-in retry handler for rate limited errors in v3.9, retrying a request after getting rate-limited is much easier than before.
- https://github.com/slackapi/python-slack-sdk/releases/tag/v3.9.0
- https://github.com/slackapi/python-slack-sdk/blob/v3.9.1/slack_sdk/http_retry/builtin_handlers.py#L52-L91
- https://github.com/slackapi/python-slack-sdk/blob/v3.9.1/slack_sdk/http_retry/builtin_async_handlers.py#L49-L88
However, getting rate-limited results in a much longer execution time as the whole operation. As a solution for this pain point, we will add a built-in traffic control layer like we do in the Java SDK: https://slack.dev/java-slack-sdk/guides/web-api-basics#rate-limits
A few points to consider for implementing this feature:
- The module manages the amount of requests in the last minute and calculate the interval before the next API call
- Metrics data can be in memory in most use cases but the part should be extensible to switch to other data storage (e.g., Redis)
- As we do in the Java SDK, running the same script/app in multiple hosts should be supported.
- For backward-compatibility, we don't turn the feature on by default. Users can enable it only when they want it.
- Both sync and async API clients should be supported in a proper way (= don't use
time.sleepin asyncio apps) - All API clients (Web API, Audit Logs, SCIM, Webhook) should have the functionality.
Category (place an x in each of the [ ])
- slack_sdk.web.WebClient (sync/async) (Web API client)
- slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
- slack_sdk.models (UI component builders)
- slack_sdk.oauth (OAuth Flow Utilities)
- slack_sdk.socket_mode (Socket Mode client)
- slack_sdk.audit_logs (Audit Logs API client)
- slack_sdk.scim (SCIM API client)
- slack_sdk.rtm (RTM client)
- slack_sdk.signature (Request Signature Verifier)
Requirements
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với các retry handler tích hợp đồng bộ và bất đồng bộ được liên kết, sau đó so sánh với hướng dẫn rate limit của Java SDK. Ánh xạ hành vi được yêu cầu trên các client Web API, Webhook, Audit Logs và SCIM. Được xem là hoàn tất khi một lớp kiểm soát lưu lượng có thể bật theo opt-in hỗ trợ các client đồng bộ và bất đồng bộ, có bộ lưu trữ metrics có thể mở rộng và không sử dụng sleep blocking trong các ứng dụng asyncio.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- api, backend-api-design, performance
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100