@@ -210,7 +210,7 @@ func TestPendingUpdatesMetrics(t *testing.T) {
210
210
cfg .StoreSyncInterval = serpent .Duration (time .Millisecond * 100 )
211
211
212
212
syncer := & syncInterceptor {Store : store }
213
- interceptor := newUpdateSignallingInterceptor (store , syncer )
213
+ interceptor := newUpdateSignallingInterceptor (syncer )
214
214
mgr , err := notifications .NewManager (cfg , interceptor , metrics , logger .Named ("manager" ))
215
215
require .NoError (t , err )
216
216
t .Cleanup (func () {
@@ -270,12 +270,12 @@ func hasMatchingFingerprint(metric *dto.Metric, fp model.Fingerprint) bool {
270
270
271
271
// fingerprintLabelPairs produces a fingerprint unique to the given combination of label pairs.
272
272
func fingerprintLabelPairs (lbs []* dto.LabelPair ) model.Fingerprint {
273
- lbsSet := model. LabelSet {}
273
+ pairs := make ([] string , 0 , len ( lbs ) * 2 )
274
274
for _ , lp := range lbs {
275
- lbsSet [ model . LabelName ( lp .GetName ())] = model . LabelValue ( lp .GetValue ())
275
+ pairs = append ( pairs , lp .GetName (), lp .GetValue ())
276
276
}
277
277
278
- return lbsSet . FastFingerprint ( )
278
+ return fingerprintLabels ( pairs ... )
279
279
}
280
280
281
281
// fingerprintLabels produces a fingerprint unique to the given pairs of label values.
@@ -295,20 +295,20 @@ func fingerprintLabels(lbs ...string) model.Fingerprint {
295
295
return lbsSet .FastFingerprint ()
296
296
}
297
297
298
+ // updateSignallingInterceptor intercepts bulk update calls to the store, and waits on the "proceed" condition to be
299
+ // signaled by the caller so it can continue.
298
300
type updateSignallingInterceptor struct {
299
301
notifications.Store
300
- * syncInterceptor
301
302
302
303
proceed * sync.Cond
303
304
304
305
updateSuccess chan int
305
306
updateFailure chan int
306
307
}
307
308
308
- func newUpdateSignallingInterceptor (store notifications.Store , interceptor * syncInterceptor ) * updateSignallingInterceptor {
309
+ func newUpdateSignallingInterceptor (interceptor notifications.Store ) * updateSignallingInterceptor {
309
310
return & updateSignallingInterceptor {
310
- Store : store ,
311
- syncInterceptor : interceptor ,
311
+ Store : interceptor ,
312
312
313
313
proceed : sync .NewCond (& sync.Mutex {}),
314
314
@@ -326,7 +326,7 @@ func (u *updateSignallingInterceptor) BulkMarkNotificationMessagesSent(ctx conte
326
326
// Wait until signaled so we have a chance to read the number of pending updates.
327
327
u .proceed .Wait ()
328
328
329
- return u .syncInterceptor .BulkMarkNotificationMessagesSent (ctx , arg )
329
+ return u .Store .BulkMarkNotificationMessagesSent (ctx , arg )
330
330
}
331
331
332
332
func (u * updateSignallingInterceptor ) BulkMarkNotificationMessagesFailed (ctx context.Context , arg database.BulkMarkNotificationMessagesFailedParams ) (int64 , error ) {
@@ -338,5 +338,5 @@ func (u *updateSignallingInterceptor) BulkMarkNotificationMessagesFailed(ctx con
338
338
// Wait until signaled so we have a chance to read the number of pending updates.
339
339
u .proceed .Wait ()
340
340
341
- return u .syncInterceptor .BulkMarkNotificationMessagesFailed (ctx , arg )
341
+ return u .Store .BulkMarkNotificationMessagesFailed (ctx , arg )
342
342
}
0 commit comments