Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: go/src/infra/monitoring/looper/looper.go

Issue 1874053002: [alerts-dispatcher] update to build again :) also fixes a concurrent map access (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: fix typo Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 package looper 1 package looper
2 2
3 import ( 3 import (
4 "expvar" 4 "expvar"
5 "time" 5 "time"
6 6
7 "github.com/luci/luci-go/common/clock" 7 "github.com/luci/luci-go/common/clock"
8 "github.com/luci/luci-go/common/logging" 8 "github.com/luci/luci-go/common/logging"
9 "golang.org/x/net/context" 9 "golang.org/x/net/context"
10 ) 10 )
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 expvars.Add("Errors", 1) 62 expvars.Add("Errors", 1)
63 if consecErrs++; consecErrs >= maxErrs { 63 if consecErrs++; consecErrs >= maxErrs {
64 ret.Success = false 64 ret.Success = false
65 return 65 return
66 } 66 }
67 } else { 67 } else {
68 consecErrs = 0 68 consecErrs = 0
69 } 69 }
70 70
71 nextCycle = cycle - dur 71 nextCycle = cycle - dur
72 » » tmr.Reset(nextCycle) 72 » » if tmr.Reset(nextCycle) {
73 » » » log.Errorf("Timer was still active")
74 » » }
73 } 75 }
74 76
75 // Run f at least once. 77 // Run f at least once.
76 run() 78 run()
77 79
78 // Keep running f until ctx is done. 80 // Keep running f until ctx is done.
79 for { 81 for {
80 » » if ar := <-tmr.GetC(); ar.Incomplete() { 82 » » select {
83 » » case <-ctx.Done():
84 » » » tmr.Stop()
81 return ret 85 return ret
82 » » } 86 » » case <-tmr.GetC():
83 » » run() 87 » » » run()
84 » » if !ret.Success { 88 » » » if !ret.Success {
85 » » » return ret 89 » » » » return ret
90 » » » }
86 } 91 }
87 } 92 }
88 } 93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698