From 48b7bb4c3529c2e0c6af08b98dfa2e7e9b720d01 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 31 May 2022 18:14:15 +0200 Subject: [PATCH] DB#Delete(): allow monitoring succeeded items --- pkg/icingadb/db.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/icingadb/db.go b/pkg/icingadb/db.go index ea0e0a96..33cbb990 100644 --- a/pkg/icingadb/db.go +++ b/pkg/icingadb/db.go @@ -582,14 +582,17 @@ func (db *DB) DeleteStreamed( // Delete creates a channel from the specified ids and // bulk deletes them by passing the channel along with the entityType to DeleteStreamed. -func (db *DB) Delete(ctx context.Context, entityType contracts.Entity, ids []interface{}) error { +// IDs for which the query ran successfully will be passed to onSuccess. +func (db *DB) Delete( + ctx context.Context, entityType contracts.Entity, ids []interface{}, onSuccess ...OnSuccess[any], +) error { idsCh := make(chan interface{}, len(ids)) for _, id := range ids { idsCh <- id } close(idsCh) - return db.DeleteStreamed(ctx, entityType, idsCh) + return db.DeleteStreamed(ctx, entityType, idsCh, onSuccess...) } func (db *DB) GetSemaphoreForTable(table string) *semaphore.Weighted {