MCPcopy Create free account
hub / github.com/buraksezer/consistent / Add

Method Add

consistent.go:244–254  ·  view source on GitHub ↗

Add adds a new member to the consistent hash circle.

(member Member)

Source from the content-addressed store, hash-verified

242
243// Add adds a new member to the consistent hash circle.
244func (c *Consistent) Add(member Member) {
245 c.mu.Lock()
246 defer c.mu.Unlock()
247
248 if _, ok := c.members[member.String()]; ok {
249 // We already have this member. Quit immediately.
250 return
251 }
252 c.add(member)
253 c.distributePartitions()
254}
255
256func (c *Consistent) delSlice(val uint64) {
257 for i := 0; i < len(c.sortedSet); i++ {

Callers 7

TestConsistentAddFunction · 0.80
TestConsistentLocateKeyFunction · 0.80
BenchmarkAddRemoveFunction · 0.80
BenchmarkLocateKeyFunction · 0.80
BenchmarkGetClosestNFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80

Calls 3

addMethod · 0.95
distributePartitionsMethod · 0.95
StringMethod · 0.65

Tested by 5

TestConsistentAddFunction · 0.64
TestConsistentLocateKeyFunction · 0.64
BenchmarkAddRemoveFunction · 0.64
BenchmarkLocateKeyFunction · 0.64
BenchmarkGetClosestNFunction · 0.64