mirror of https://github.com/coder/coder.git
21 lines
520 B
Go
21 lines
520 B
Go
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 (
|
|
LockIDDeploymentSetup = iota + 1
|
|
LockIDEnterpriseDeploymentSetup
|
|
LockIDDBRollup
|
|
LockIDDBPurge
|
|
)
|
|
|
|
// 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())
|
|
}
|