Skip to content

Commit

Permalink
fix(usage/ping): avoid stale data when pinging (#9)
Browse files Browse the repository at this point in the history
Signed-off-by: Niladri Halder <[email protected]>
  • Loading branch information
niladrih authored Jun 25, 2024
1 parent cf0a565 commit 17f9b1f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions usage/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,23 @@ const (
func PingCheck(engineName, category string, pingImmediately bool) {
// Create a new usage field
u := New()
pingSender := u.CommonBuild(engineName).
InstallBuilder(true).
SetCategory(category)

if pingImmediately {
// Ping immediately.
pingSender.Send()
u.CommonBuild(engineName).
InstallBuilder(true).
SetCategory(category).
Send()
}

duration := getPingPeriod()
ticker := time.NewTicker(duration)
for range ticker.C {
// Ping periodically, starting at 'duration'.
pingSender.Send()
u.CommonBuild(engineName).
InstallBuilder(true).
SetCategory(category).
Send()
}
}

Expand Down

0 comments on commit 17f9b1f

Please sign in to comment.