fix(guangyapan): rate-limit API requests to avoid flooding on batch copy#9553
Open
okatu-loli wants to merge 1 commit into
Open
fix(guangyapan): rate-limit API requests to avoid flooding on batch copy#9553okatu-loli wants to merge 1 commit into
okatu-loli wants to merge 1 commit into
Conversation
Every GuangYaPan API call funnels through postAPI with no throttling, so copying many files cross-storage fired unthrottled Link/copy/list requests and overwhelmed the upstream API. Other Chinese pan drivers (123, aliyundrive_open) self-throttle; guangya did not. Add a per-endpoint rate.Limiter (one request per 500ms, applied in postAPI), mirroring the 123 driver's APIRateLimit pattern, so concurrent copy tasks are paced instead of flooding.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
光鸭(GuangYaPan)驱动所有 API 请求都经过
postAPI,但没有任何限流。跨盘复制多个文件时,每个复制任务都会并发调用光鸭接口(Link/get_res_download_url、copy_file、get_file_list等),瞬间打满上游接口、被风控。其它国产网盘驱动(如123、aliyundrive_open)都自带限流,光鸭没有,所以表现为「复制多个文件到其他网盘时任务数/请求不受控」。修改
在
postAPI入口加一个 per-endpoint 的rate.Limiter(每个接口路径 500ms 一次,burst 1),参照123驱动的APIRateLimit模式。这样并发的复制任务会被按节奏排队,而不是同时打满光鸭接口;不同接口(列目录 / 取链接 / 复制)各自独立限流,互不影响。GuangYaPan.apiRateLimit sync.Map与常量apiRateInterval = 500msapiRateLimitWait(ctx, path),在postAPI发请求前调用影响
postAPI的操作(List/Link/Copy/Move 等)都会被限流,行为与其它「正常」网盘一致。123驱动相同。测试
go build ./drivers/guangyapan/通过。