8000 feat(traffic): support limit task worker count & file stream rate by KirCute · Pull Request #7948 · AlistGo/alist · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(traffic): support limit task worker count & file stream rate #7948

New issue

Have a 10000 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

Merged
merged 6 commits into from
Feb 16, 2025

Conversation

KirCute
Copy link
Contributor
@KirCute KirCute commented Feb 5, 2025

支持限制 6 种任务的线程数和传输上下行速率。

  1. 增加op.RegisterSettingChangingCallback方法用来注册一个当设置发生修改时调用的回调函数,这使得设置修改后立即生效成为可能。
  2. xhofe/tache升级到 v0.1.5,使用新版本的SetWorkersNumActive方法实现运行时修改任务线程数。
  3. 增加四个基于golang.org/x/time/rateLimiter的限流器:
    • ClientDownloadLimit:限制/p/d/ap/ad/ae五个API,WebDAV 服务器的 GET、POST 请求和 FTP 服务器的 RETR 命令的下行速率。
    • ClientUploadLimit:限制/api/fs/put/api/fs/form两个API,WebDAV 服务器的 PUT 请求和 FTP 服务器的 STOR 命令的上行速率。
    • ServerDownloadLimit:限制stream.SeekableStream和本地代理读取model.Link的速率。
    • ServerUploadLimit:限制驱动上传model.FileStreamer的速率,这一步需要在驱动内完成,这也是为什么这个 PR 修改了几乎所有可写驱动。

Front-end part AlistGo/alist-web#250

Close #7511

Comment on lines 179 to 186
err = jsoniter.Unmarshal(body, &erron)
if err != nil {
return nil, err
}
err = xml.Unmarshal(body, &erron)
if err != nil {
return nil, err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里别改,故意忽略错误的。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@xhofe xhofe merged commit 3b71500 into AlistGo:main Feb 16, 2025
12 checks passed
@KirCute
Copy link
Contributor Author
KirCute commented Feb 16, 2025

@xhofe 这个前端没有合并

@anwen-anyi
Copy link
Collaborator

佬,这个PR的任务和 [data/config.json] 配置文件的任务、线程 是分别生效的吗?还是怎么运作的

@KirCute
Copy link
Contributor Author
KirCute commented Apr 3, 2025

佬,这个PR的任务和 [data/config.json] 配置文件的任务、线程 是分别生效的吗?还是怎么运作的

如果settings里没有线程数那个字段(第一次运行或者刚从旧版本升级上来的时候),会用config里的值初始化settings,如果settings里有值就会忽略config里的

@lee-cq
Copy link
Contributor
lee-cq commented Apr 5, 2025

大佬,请教下,这个PR实现的是对单个连接的限制,还是多个连接同时下载时的总速率。

@KirCute
Copy link
Contributor Author
KirCute commented Apr 5, 2025

大佬,请教下,这个PR实现的是对单个连接的限制,还是多个连接同时下载时的总速率。

总的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

能否添加自定义限速功能
5 participants
0