GetAverageLoad calculates and returns the current average load across all members. It is a public method that provides thread-safe access to the load calculation.
()
| 147 | // GetAverageLoad calculates and returns the current average load across all members. |
| 148 | // It is a public method that provides thread-safe access to the load calculation. |
| 149 | func (c *Consistent) GetAverageLoad() float64 { |
| 150 | // Acquire a read lock to ensure thread-safe access to shared resources. |
| 151 | c.mu.RLock() |
| 152 | defer c.mu.RUnlock() |
| 153 | |
| 154 | // Delegate the actual load calculation to the internal helper method. |
| 155 | return c.calculateAverageLoad() |
| 156 | } |
| 157 | |
| 158 | // calculateAverageLoad is a private helper method that performs the actual calculation |
| 159 | // of the average load across all members. It is not thread-safe and should be called |
no test coverage detected