MCPcopy Create free account
hub / github.com/Permify/permify / LocateKey

Method LocateKey

pkg/consistent/consistent.go:402–408  ·  view source on GitHub ↗

LocateKey determines the owner of the partition corresponding to the given key. It calculates the partition ID for the key and retrieves the associated member in a thread-safe manner.

(key []byte)

Source from the content-addressed store, hash-verified

400// LocateKey determines the owner of the partition corresponding to the given key.
401// It calculates the partition ID for the key and retrieves the associated member in a thread-safe manner.
402func (c *Consistent) LocateKey(key []byte) Member {
403 // Calculate the partition ID based on the hash of the key.
404 partitionID := c.GetPartitionID(key)
405
406 // Retrieve the owner of the partition using the thread-safe method.
407 return c.GetPartitionOwner(partitionID)
408}
409
410// closestN retrieves the closest N members to the given partition ID in the consistent hash ring.
411// It ensures thread-safe access and validates that the requested count of members can be satisfied.

Callers 1

consistent_test.goFile · 0.80

Calls 2

GetPartitionIDMethod · 0.95
GetPartitionOwnerMethod · 0.95

Tested by

no test coverage detected