MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / hashKey

Function hashKey

app/controlplane/pkg/data/lock.go:97–101  ·  view source on GitHub ↗

hashKey turns an opaque string key into the int64 that pg_advisory_lock expects. FNV-1a gives a stable, well-distributed mapping with effectively no collision risk for the handful of named locks this package uses.

(key string)

Source from the content-addressed store, hash-verified

95// mapping with effectively no collision risk for the handful of named
96// locks this package uses.
97func hashKey(key string) int64 {
98 h := fnv.New64a()
99 _, _ = h.Write([]byte(key))
100 return int64(h.Sum64()) //nolint:gosec // intentional wraparound; pg accepts any int64
101}

Callers 1

TryAcquireMethod · 0.85

Calls 1

WriteMethod · 0.65

Tested by

no test coverage detected