Skip to content

Commit a5dd590

Browse files
author
Evan Damon
committed
Fix and optimize request rate wait time
1 parent ebc9ec8 commit a5dd590

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

cmd/logshare-cli/main.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,11 @@ func run(conf *config) func(c *cli.Context) error {
119119
hourStart := conf.startTime
120120
hourEnd := hourStart + 3600
121121
var previousRequest time.Time
122-
var requestGap time.Duration
123122
for hourStart < conf.endTime {
124123
if hourEnd > conf.endTime {
125124
hourEnd = conf.endTime
126125
}
127-
requestGap = time.Since(previousRequest)
128-
if requestGap.Seconds() < 5 {
129-
time.Sleep(requestGap)
130-
}
126+
time.Sleep(5 * time.Second - time.Since(previousRequest))
131127
previousRequest = time.Now()
132128
meta, err = client.GetFromTimestamp(
133129
conf.zoneID, hourStart, hourEnd, conf.count)

0 commit comments

Comments
 (0)