2023-06-25 23:17:00 +10:00
|
|
|
package database
|
|
|
|
|
|
|
|
|
|
import "hash/fnv"
|
|
|
|
|
|
|
|
|
|
// Well-known lock IDs for lock functions in the database. These should not
|
|
|
|
|
// change. If locks are deprecated, they should be kept in this list to avoid
|
|
|
|
|
// reusing the same ID.
|
|
|
|
|
const (
|
2024-03-22 18:42:43 +02:00
|
|
|
LockIDDeploymentSetup = iota + 1
|
2024-02-28 08:14:11 -08:00
|
|
|
LockIDEnterpriseDeploymentSetup
|
2024-03-22 18:42:43 +02:00
|
|
|
LockIDDBRollup
|
2024-04-22 14:10:32 +03:00
|
|
|
LockIDDBPurge
|
2024-09-18 09:11:44 +02:00
|
|
|
LockIDNotificationsReportGenerator
|
2024-09-19 19:12:44 +01:00
|
|
|
LockIDCryptoKeyRotation
|
2025-04-17 09:29:29 -04:00
|
|
|
LockIDReconcilePrebuilds
|
2026-01-12 18:19:19 -08:00
|
|
|
LockIDReconcileSystemRoles
|
2026-02-06 09:52:17 -07:00
|
|
|
LockIDBoundaryUsageStats
|
2023-06-25 23:17:00 +10:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// GenLockID generates a unique and consistent lock ID from a given string.
|
|
|
|
|
func GenLockID(name string) int64 {
|
|
|
|
|
hash := fnv.New64()
|
|
|
|
|
_, _ = hash.Write([]byte(name))
|
2025-03-26 01:56:39 -05:00
|
|
|
// #nosec G115 - Safe conversion as FNV hash should be treated as random value and both uint64/int64 have the same range of unique values
|
2023-06-25 23:17:00 +10:00
|
|
|
return int64(hash.Sum64())
|
|
|
|
|
}
|