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

Add request token sending counter #353

Merged
merged 1 commit into from
Nov 27, 2023
Merged

Add request token sending counter #353

merged 1 commit into from
Nov 27, 2023

Conversation

ii2day
Copy link
Collaborator

@ii2day ii2day commented Nov 24, 2023

添加 发送 token 的计数器,避免多发送 token

Copy link

codecov bot commented Nov 24, 2023

Codecov Report

Merging #353 (c8dc481) into main (2e624fc) will decrease coverage by 0.18%.
Report is 2 commits behind head on main.
The diff coverage is 71.42%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #353      +/-   ##
==========================================
- Coverage   80.50%   80.33%   -0.18%     
==========================================
  Files          22       22              
  Lines        1611     1632      +21     
==========================================
+ Hits         1297     1311      +14     
- Misses        235      239       +4     
- Partials       79       82       +3     
Flag Coverage Δ
unittests 80.33% <71.42%> (-0.18%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
pkg/loadRequest/loadDns/dns_requester.go 81.69% <70.00%> (-0.58%) ⬇️
pkg/loadRequest/loadHttp/http_requester.go 86.22% <72.72%> (-0.70%) ⬇️

... and 1 file with indirect coverage changes

defer ticker.Stop()
// The request should be sent immediately at 0 seconds
// The request should be sent immediately at 0.5 seconds
time.Sleep(time.Millisecond * 500)
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里吃掉 0.5s 是什么打算,这也让任务的总体发压时间减了 0.5

Copy link
Collaborator Author

@ii2day ii2day Nov 26, 2023

Choose a reason for hiding this comment

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

这里没有吃掉0.5秒,是第0.5秒发第一轮,1.5发第二轮,2.5发第三轮,以此类推。以前是第0秒发一次轮,第1秒发第二轮,第2秒发第三轮。由于结束的定时器也是整秒进行结束的,所以会因为轻微误差导致多发一轮,所以改到0.5秒发

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

比如我想发压5秒,之前的逻辑是0,1,2,3,4发送,现在改为0.5,1.5,2.5,3.5,4.5 发送的轮数是一样的,为了跟定时结束的定时器错开时间

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

发压定时器
0秒------第1次
1秒------第2次
2秒------第3次
3秒------第4次
4秒------第5次
5秒------可能因为误差channel比结束定时器先发送了,导致多请求一轮

Signed-off-by: ii2day <ji.li@daocloud.io>
@ii2day ii2day changed the title Optimize request time Add request token sending counter Nov 27, 2023
@weizhoublue weizhoublue merged commit be4944b into main Nov 27, 2023
22 checks passed
@weizhoublue weizhoublue deleted the pr/ii2day/request branch November 27, 2023 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants