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

Method GetLoadDistribution

pkg/consistent/consistent.go:351–363  ·  view source on GitHub ↗

GetLoadDistribution provides a thread-safe snapshot of the current load distribution across members. It returns a map where the keys are member identifiers and the values are their respective loads.

()

Source from the content-addressed store, hash-verified

349// GetLoadDistribution provides a thread-safe snapshot of the current load distribution across members.
350// It returns a map where the keys are member identifiers and the values are their respective loads.
351func (c *Consistent) GetLoadDistribution() map[string]float64 {
352 // Acquire a read lock to ensure thread-safe access to the loads map.
353 c.mu.RLock()
354 defer c.mu.RUnlock()
355
356 // Create a copy of the loads map to avoid exposing internal state.
357 loadDistribution := make(map[string]float64)
358 for memberName, memberLoad := range c.loads {
359 loadDistribution[memberName] = memberLoad
360 }
361
362 return loadDistribution
363}
364
365// GetPartitionID calculates and returns the partition ID for a given key.
366// The partition ID is determined by hashing the key and applying modulo operation with the partition count.

Callers 1

consistent_test.goFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected