-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(stream): enhance GetRangeReaderFromLink rate limiting #1528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… RateLimitWriter, and RateLimitFile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the rate limiting logic for range readers and consolidates duplicate code. The main focus is on cleaning up how RateLimitReader is applied and removing redundant wrapper types.
- Simplified rate limiting logic by applying
RateLimitReaderdirectly inGetRangeReaderFromLinkinstead of wrapping withRateLimitRangeReaderFunc - Removed the need for
FileRangeReaderwrapper in driver-level Link implementations where the underlying reader doesn't actually support file operations - Improved context error checking by replacing the custom
utils.IsCanceledcheck with directCtx.Err()calls
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/stream/util.go | Restructured GetRangeReaderFromLink to apply rate limiting at HTTP client level for both URL and RangeReader paths; changed return type of GetRangeReaderFromMFile to *model.FileRangeReader |
| internal/stream/limit.go | Simplified context cancellation checks by using Ctx.Err() directly; optimized RateLimitRangeReaderFunc to check for nil limiter before executing |
| internal/net/util.go | Replaced custom LimitedReadCloser implementation with readers.NewLimitedReadCloser from rclone library |
| internal/model/file.go | Added documentation comment explaining the purpose of FileRangeReader wrapper |
| internal/model/args.go | Changed ContentLength field JSON tag from "-" to "content_length" to enable serialization |
| drivers/proton_drive/driver.go | Removed unnecessary FileRangeReader wrapper as the underlying reader doesn't support file operations |
| drivers/ftp/driver.go | Removed unnecessary FileRangeReader wrapper as the underlying reader doesn't support file operations |
Comments suppressed due to low confidence (1)
internal/stream/util.go:113
- Corrected spelling of 'perfromace' to 'performance'.
log.Warnf("remote http server not supporting range request, expect low perfromace!")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description / 描述
url并发下载支持速率限制
Motivation and Context / 背景
How Has This Been Tested? / 测试
Checklist / 检查清单
我已阅读 CONTRIBUTING 文档。
go fmtor prettier.我已使用
go fmt或 prettier 格式化提交的代码。我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
我已相应更新了相关仓库(若适用)。