mirror of
https://github.com/Icinga/icingadb.git
synced 2026-06-06 15:22:08 -04:00
Move method DB.getSemaphoreForTable()
This commit is contained in:
parent
44b45fc429
commit
16dd4663ad
1 changed files with 13 additions and 13 deletions
|
|
@ -496,6 +496,19 @@ 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 {
|
||||
db.tableSemaphoresMu.Lock()
|
||||
defer db.tableSemaphoresMu.Unlock()
|
||||
|
||||
if sem, ok := db.tableSemaphores[table]; ok {
|
||||
return sem
|
||||
} else {
|
||||
sem = semaphore.NewWeighted(int64(db.Options.MaxConnectionsPerTable))
|
||||
db.tableSemaphores[table] = sem
|
||||
return sem
|
||||
}
|
||||
}
|
||||
|
||||
// IsRetryable checks whether the given error is retryable.
|
||||
func IsRetryable(err error) bool {
|
||||
if errors.Is(err, driver.ErrBadConn) {
|
||||
|
|
@ -520,16 +533,3 @@ func IsRetryable(err error) bool {
|
|||
|
||||
return false
|
||||
}
|
||||
|
||||
func (db *DB) getSemaphoreForTable(table string) *semaphore.Weighted {
|
||||
db.tableSemaphoresMu.Lock()
|
||||
defer db.tableSemaphoresMu.Unlock()
|
||||
|
||||
if sem, ok := db.tableSemaphores[table]; ok {
|
||||
return sem
|
||||
} else {
|
||||
sem = semaphore.NewWeighted(int64(db.Options.MaxConnectionsPerTable))
|
||||
db.tableSemaphores[table] = sem
|
||||
return sem
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue