Skip to content

perf(alias): add timeout when List and Link #8416

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

xrgzs
Copy link
Contributor

@xrgzs xrgzs commented Apr 20, 2025

为别名驱动的 List 和 Link 操作新增超时自动切换选项,当某个存储出现故障或性能下降时,能够自动切换到下一个存储,避免长时间卡住而影响体验。

@Mmx233
Copy link
Contributor

Mmx233 commented May 8, 2025

Using defer in loops is dangerous, and how did you land on 1 second?

@xrgzs xrgzs force-pushed the perf/alias-timeout branch from 2050b74 to c877c91 Compare May 8, 2025 09:06
@xrgzs
Copy link
Contributor Author

xrgzs commented May 8, 2025

Using defer in loops is dangerous, and how did you land on 1 second?

感谢 review!包含 defer 的部分已删除。此问题由 上次 PR 时 AI 助理错误要求修改所引入。由于操作失误重新开此 PR。

另外不太清楚您说的 land on 是什么意思。如果我没理解错的话,context.WithTimeout 函数的第二个参数需要 time.Duration 类型,这里的 time.Duration(d.Timeout) 将 int 类型的 d.Timeout 转换为 time.Duration 类型,然后再与 time.Second 相乘,这样就能得到正确的 time.Duration 类型的超时时间。不能直接使用 int 类型与 time.Second 相乘,否则会报错:invalid operation: d.Timeout * time.Second (mismatched types int and time.Duration)compiler[MismatchedTypes](https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MismatchedTypes)

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.

2 participants