From d017a05d052a75cab97773ccb38d488b2e971b98 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 30 Sep 2021 15:27:46 +0200 Subject: [PATCH] Export DB.getSemaphoreForTable() --- pkg/icingadb/db.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/icingadb/db.go b/pkg/icingadb/db.go index 9a6dbb16..247be2a6 100644 --- a/pkg/icingadb/db.go +++ b/pkg/icingadb/db.go @@ -438,7 +438,7 @@ func (db *DB) CreateStreamed(ctx context.Context, entities <-chan contracts.Enti return errors.Wrap(err, "can't copy first entity") } - sem := db.getSemaphoreForTable(utils.TableName(first)) + sem := db.GetSemaphoreForTable(utils.TableName(first)) stmt, placeholders := db.BuildInsertStmt(first) return db.NamedBulkExec(ctx, stmt, db.BatchSizeByPlaceholders(placeholders), sem, forward, nil) @@ -454,7 +454,7 @@ func (db *DB) UpsertStreamed(ctx context.Context, entities <-chan contracts.Enti return errors.Wrap(err, "can't copy first entity") } - sem := db.getSemaphoreForTable(utils.TableName(first)) + sem := db.GetSemaphoreForTable(utils.TableName(first)) stmt, placeholders := db.BuildUpsertStmt(first) return db.NamedBulkExec(ctx, stmt, db.BatchSizeByPlaceholders(placeholders), sem, forward, succeeded) @@ -469,7 +469,7 @@ func (db *DB) UpdateStreamed(ctx context.Context, entities <-chan contracts.Enti if first == nil { return errors.Wrap(err, "can't copy first entity") } - sem := db.getSemaphoreForTable(utils.TableName(first)) + sem := db.GetSemaphoreForTable(utils.TableName(first)) stmt, _ := db.BuildUpdateStmt(first) return db.NamedBulkExecTx(ctx, stmt, db.Options.MaxRowsPerTransaction, sem, forward) @@ -480,7 +480,7 @@ func (db *DB) UpdateStreamed(ctx context.Context, entities <-chan contracts.Enti // Bulk size is controlled via Options.MaxPlaceholdersPerStatement and // concurrency is controlled via Options.MaxConnectionsPerTable. func (db *DB) DeleteStreamed(ctx context.Context, entityType contracts.Entity, ids <-chan interface{}) error { - sem := db.getSemaphoreForTable(utils.TableName(entityType)) + sem := db.GetSemaphoreForTable(utils.TableName(entityType)) return db.BulkExec(ctx, db.BuildDeleteStmt(entityType), db.Options.MaxPlaceholdersPerStatement, sem, ids) } @@ -496,7 +496,7 @@ func (db *DB) Delete(ctx context.Context, entityType contracts.Entity, ids []int return db.DeleteStreamed(ctx, entityType, idsCh) } -func (db *DB) getSemaphoreForTable(table string) *semaphore.Weighted { +func (db *DB) GetSemaphoreForTable(table string) *semaphore.Weighted { db.tableSemaphoresMu.Lock() defer db.tableSemaphoresMu.Unlock()