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)
| 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. |
| 402 | func (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. |
no test coverage detected