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

a timer make code more robust #559

Closed
wants to merge 2 commits into from
Closed

Conversation

haifeiWu
Copy link
Contributor

use a timer replace time.Sleep(1 * time.Second) make code rebust

@codecov-commenter
Copy link

Codecov Report

Base: 31.08% // Head: 31.13% // Increases project coverage by +0.04% 🎉

Coverage data is based on head (41d26e2) compared to base (cb83715).
Patch coverage: 50.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #559      +/-   ##
==========================================
+ Coverage   31.08%   31.13%   +0.04%     
==========================================
  Files          40       40              
  Lines        2985     2987       +2     
==========================================
+ Hits          928      930       +2     
- Misses       1991     1992       +1     
+ Partials       66       65       -1     
Impacted Files Coverage Δ
clients/naming_client/service_info_updater.go 34.28% <50.00%> (-2.08%) ⬇️
.../naming_client/naming_cache/service_info_holder.go 25.26% <0.00%> (-2.11%) ⬇️
clients/naming_client/naming_http/beat_reactor.go 75.00% <0.00%> (+5.00%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -47,11 +47,13 @@ func NewServiceInfoUpdater(ctx context.Context, serviceInfoHolder *naming_cache.

func (s *ServiceInfoUpdater) asyncUpdateService() {
sema := util.NewSemaphore(s.updateThreadNum)
duration := 1 * time.Second
timer := time.NewTimer(duration) // new timer
Copy link
Member

Choose a reason for hiding this comment

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

The underlying implementation of timer is no different from sleep

@haifeiWu haifeiWu closed this Jan 30, 2023
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.

3 participants