diff --git a/consistenthash/consistenthash.go b/consistenthash/consistenthash.go index a9c56f0..da13909 100644 --- a/consistenthash/consistenthash.go +++ b/consistenthash/consistenthash.go @@ -44,12 +44,12 @@ func New(replicas int, fn Hash) *Map { return m } -// Returns true if there are no items available. +// IsEmpty returns true if there are no items available. func (m *Map) IsEmpty() bool { return len(m.keys) == 0 } -// Adds some keys to the hash. +// Add adds some keys to the hash. func (m *Map) Add(keys ...string) { for _, key := range keys { for i := 0; i < m.replicas; i++ { @@ -61,7 +61,7 @@ func (m *Map) Add(keys ...string) { sort.Ints(m.keys) } -// Gets the closest item in the hash to the provided key. +// Get gets the closest item in the hash to the provided key. func (m *Map) Get(key string) string { if m.IsEmpty() { return "" diff --git a/groupcache_test.go b/groupcache_test.go index ea05cac..ffbd0b9 100644 --- a/groupcache_test.go +++ b/groupcache_test.go @@ -78,7 +78,7 @@ func testSetup() { })) } -// tests that a Getter's Get method is only called once with two +// TestGetDupSuppressString tests that a Getter's Get method is only called once with two // outstanding callers. This is the string variant. func TestGetDupSuppressString(t *testing.T) { once.Do(testSetup) @@ -120,7 +120,7 @@ func TestGetDupSuppressString(t *testing.T) { } } -// tests that a Getter's Get method is only called once with two +// TestGetDupSuppressProto tests that a Getter's Get method is only called once with two // outstanding callers. This is the proto variant. func TestGetDupSuppressProto(t *testing.T) { once.Do(testSetup) @@ -249,7 +249,7 @@ func (p fakePeers) PickPeer(key string) (peer ProtoGetter, ok bool) { return p[n], p[n] != nil } -// tests that peers (virtual, in-process) are hit, and how much. +// TestPeers tests that peers (virtual, in-process) are hit, and how much. func TestPeers(t *testing.T) { once.Do(testSetup) rand.Seed(123)