2023-06-25 13:17:00 +00: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 16:42:43 +00:00
|
|
|
LockIDDeploymentSetup = iota + 1
|
2024-02-28 16:14:11 +00:00
|
|
|
LockIDEnterpriseDeploymentSetup
|
2024-03-22 16:42:43 +00:00
|
|
|
LockIDDBRollup
|
2024-04-22 11:10:32 +00:00
|
|
|
LockIDDBPurge
|
2023-06-25 13:17:00 +00: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))
|
|
|
|
return int64(hash.Sum64())
|
|
|
|
}
|