@@ -2,7 +2,6 @@ package notifications_test
2
2
3
3
import (
4
4
"context"
5
- "sync"
6
5
"testing"
7
6
"time"
8
7
@@ -260,7 +259,7 @@ func TestPendingUpdatesMetric(t *testing.T) {
260
259
require .EqualValues (t , pending , success + failure )
261
260
262
261
// Unpause the interceptor so the updates can proceed.
263
- interceptor .proceed . Broadcast ()
262
+ interceptor .unpause ()
264
263
265
264
// Validate that the store synced the expected number of updates.
266
265
require .Eventually (t , func () bool {
@@ -376,7 +375,7 @@ func fingerprintLabels(lbs ...string) model.Fingerprint {
376
375
type updateSignallingInterceptor struct {
377
376
notifications.Store
378
377
379
- proceed * sync. Cond
378
+ pause chan any
380
379
381
380
updateSuccess chan int
382
381
updateFailure chan int
@@ -386,33 +385,31 @@ func newUpdateSignallingInterceptor(interceptor notifications.Store) *updateSign
386
385
return & updateSignallingInterceptor {
387
386
Store : interceptor ,
388
387
389
- proceed : sync . NewCond ( & sync. Mutex {} ),
388
+ pause : make ( chan any , 1 ),
390
389
391
390
updateSuccess : make (chan int , 1 ),
392
391
updateFailure : make (chan int , 1 ),
393
392
}
394
393
}
395
394
395
+ func (u * updateSignallingInterceptor ) unpause () {
396
+ close (u .pause )
397
+ }
398
+
396
399
func (u * updateSignallingInterceptor ) BulkMarkNotificationMessagesSent (ctx context.Context , arg database.BulkMarkNotificationMessagesSentParams ) (int64 , error ) {
397
400
u .updateSuccess <- len (arg .IDs )
398
401
399
- u .proceed .L .Lock ()
400
- defer u .proceed .L .Unlock ()
401
-
402
402
// Wait until signaled so we have a chance to read the number of pending updates.
403
- u . proceed . Wait ()
403
+ <- u . pause
404
404
405
405
return u .Store .BulkMarkNotificationMessagesSent (ctx , arg )
406
406
}
407
407
408
408
func (u * updateSignallingInterceptor ) BulkMarkNotificationMessagesFailed (ctx context.Context , arg database.BulkMarkNotificationMessagesFailedParams ) (int64 , error ) {
409
409
u .updateFailure <- len (arg .IDs )
410
410
411
- u .proceed .L .Lock ()
412
- defer u .proceed .L .Unlock ()
413
-
414
411
// Wait until signaled so we have a chance to read the number of pending updates.
415
- u . proceed . Wait ()
412
+ <- u . pause
416
413
417
414
return u .Store .BulkMarkNotificationMessagesFailed (ctx , arg )
418
415
}
0 commit comments