Skip to content
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

[BUG] 发送请求时,修改全局 HTTP Client Timeout 引发数据不一致 #91

Open
shuqingzai opened this issue Aug 17, 2024 · 0 comments

Comments

@shuqingzai
Copy link

在初始化 BceClient 时,可以设置 bce.BceClient.ConnectionTimeoutInMillis 控制连接超时时间,但是在每次请求是都会通过该值改变全局 http.ClientTimeout 属性,而 ConnectionTimeoutInMillis 可以在动态调整,导致会有并发数据竞争

  1. 发送请求时全局修改 http.Client
    httpClient.Timeout = time.Duration(request.Timeout()) * time.Second
  2. 每次构建 request 时设置 ConnectionTimeoutInMillis
    request.SetTimeout(c.Config.ConnectionTimeoutInMillis / 1000)
  3. bce.BceClient.ConnectionTimeoutInMillis 可以在外部随意动态修改,导致会有并发数据竞争
  4. 是否可以引入 context 控制单个请求,而不是随意修改全局变量
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

No branches or pull requests

1 participant