File tree Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -204,7 +204,7 @@ func run() int {
204204 })
205205
206206 syncStart := time .Now ()
207- atomic . StoreInt64 ( & telemetry .OngoingSyncStartMilli , syncStart .UnixMilli ())
207+ telemetry .OngoingSyncStartMilli . Store ( syncStart .UnixMilli ())
208208
209209 logger .Info ("Starting config sync" )
210210 for _ , factory := range v1 .ConfigFactories {
@@ -244,7 +244,7 @@ func run() int {
244244
245245 g .Go (func () error {
246246 configInitSync .Wait ()
247- atomic . StoreInt64 ( & telemetry .OngoingSyncStartMilli , 0 )
247+ telemetry .OngoingSyncStartMilli . Store ( 0 )
248248
249249 syncEnd := time .Now ()
250250 elapsed := syncEnd .Sub (syncStart )
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ const Timeout = time.Minute
2424type Heartbeat struct {
2525 active bool
2626 events chan * HeartbeatMessage
27- lastReceivedMs int64
27+ lastReceivedMs atomic. Int64
2828 cancelCtx context.CancelFunc
2929 client * redis.Client
3030 done chan struct {}
@@ -59,7 +59,7 @@ func (h *Heartbeat) Events() <-chan *HeartbeatMessage {
5959
6060// LastReceived returns the last heartbeat's receive time in ms.
6161func (h * Heartbeat ) LastReceived () int64 {
62- return atomic . LoadInt64 ( & h .lastReceivedMs )
62+ return h .lastReceivedMs . Load ( )
6363}
6464
6565// Close stops the heartbeat controller loop, waits for it to finish, and returns an error if any.
@@ -138,7 +138,7 @@ func (h *Heartbeat) controller(ctx context.Context) {
138138 h .active = true
139139 }
140140
141- atomic . StoreInt64 ( & h .lastReceivedMs , m .received .UnixMilli ())
141+ h .lastReceivedMs . Store ( m .received .UnixMilli ())
142142 h .sendEvent (m )
143143 case <- time .After (Timeout ):
144144 if h .active {
@@ -149,7 +149,7 @@ func (h *Heartbeat) controller(ctx context.Context) {
149149 h .logger .Warn ("Waiting for Icinga heartbeat" )
150150 }
151151
152- atomic . StoreInt64 ( & h .lastReceivedMs , 0 )
152+ h .lastReceivedMs . Store ( 0 )
153153 case <- ctx .Done ():
154154 return ctx .Err ()
155155 }
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ func GetCurrentDbConnErr() (string, int64) {
7777}
7878
7979// OngoingSyncStartMilli is to be updated by the main() function.
80- var OngoingSyncStartMilli int64
80+ var OngoingSyncStartMilli atomic. Int64
8181
8282var boolToStr = map [bool ]string {false : "0" , true : "1" }
8383var startTime = time .Now ().UnixMilli ()
@@ -100,7 +100,7 @@ func StartHeartbeat(
100100 periodic .Start (ctx , interval , func (tick periodic.Tick ) {
101101 heartbeat := heartbeat .LastReceived ()
102102 responsibleTsMilli , responsible , otherResponsible := ha .State ()
103- ongoingSyncStart := atomic . LoadInt64 ( & OngoingSyncStartMilli )
103+ ongoingSyncStart := OngoingSyncStartMilli . Load ( )
104104 lastSync := syncStats .Load ()
105105 dbConnErr , dbConnErrSinceMilli := GetCurrentDbConnErr ()
106106 now := time .Now ()
You can’t perform that action at this time.
0 commit comments