Skip to content

Commit b7e79bd

Browse files
committed
cmd/gopherbot: use releases cache for an hour
The previous condition could never be true (unless the current time went back by more than an hour), so the cached releases.major value was never used. An HTTP request to the remote server was made on each getMajorReleases call. This change fixes the condition to use the cached releases.major value within an hour of fetching it. Updates golang/go#24899 Change-Id: I71da1b2503075db878b371606436130931dbcc0d Reviewed-on: https://go-review.googlesource.com/c/147437 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 2850507 commit b7e79bd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cmd/gopherbot/gopherbot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ func (b *gopherbot) onLatestCL(ctx context.Context, cl *maintner.GerritCL, f fun
11831183
func (b *gopherbot) getMajorReleases(ctx context.Context) ([]string, error) {
11841184
b.releases.Lock()
11851185
defer b.releases.Unlock()
1186-
if b.releases.lastUpdate.After(time.Now().Add(time.Hour)) {
1186+
if expiry := b.releases.lastUpdate.Add(time.Hour); time.Now().Before(expiry) {
11871187
return b.releases.major, nil
11881188
}
11891189
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)

0 commit comments

Comments
 (0)