MCPcopy Index your code
hub / github.com/Permify/permify / Add

Method Add

pkg/consistent/consistent.go:285–298  ·  view source on GitHub ↗

Add safely adds a new member to the consistent hash circle. It ensures thread safety and redistributes partitions after adding the member.

(member Member)

Source from the content-addressed store, hash-verified

283// Add safely adds a new member to the consistent hash circle.
284// It ensures thread safety and redistributes partitions after adding the member.
285func (c *Consistent) Add(member Member) {
286 // Acquire a write lock to ensure thread safety.
287 c.mu.Lock()
288 defer c.mu.Unlock()
289
290 // Check if the member already exists in the ring. If it does, exit early.
291 if _, exists := c.members[member.String()]; exists {
292 return
293 }
294
295 // Add the member to the ring and redistribute partitions.
296 c.addMemberToRing(member)
297 c.distributePartitions()
298}
299
300// removeFromSortedSet removes a hash value from the sorted set of hashes.
301func (c *Consistent) removeFromSortedSet(hashValue uint64) {

Callers 1

consistent_test.goFile · 0.45

Calls 3

addMemberToRingMethod · 0.95
distributePartitionsMethod · 0.95
StringMethod · 0.65

Tested by

no test coverage detected