lease: Rename `Poll` to `Peek` in the `LeaseExpiredNotifier`

`Poll` means that the elements in the heap will be removed.
And it is more appropriate to use `Peek` to get the top of the heap.

Signed-off-by: SimFG <1142838399@qq.com>
dependabot/go_modules/go.uber.org/atomic-1.10.0
SimFG 2022-07-07 11:43:54 +08:00
parent 248f072370
commit e586dc19df
3 changed files with 6 additions and 6 deletions

View File

@ -96,7 +96,7 @@ func (mq *LeaseExpiredNotifier) Unregister() *LeaseWithTime {
return item
}
func (mq *LeaseExpiredNotifier) Poll() *LeaseWithTime {
func (mq *LeaseExpiredNotifier) Peek() *LeaseWithTime {
if mq.Len() == 0 {
return nil
}

View File

@ -40,8 +40,8 @@ func TestLeaseQueue(t *testing.T) {
}
// first element is expired.
if le.leaseExpiredNotifier.Poll().id != LeaseID(1) {
t.Fatalf("first item expected lease ID %d, got %d", LeaseID(1), le.leaseExpiredNotifier.Poll().id)
if le.leaseExpiredNotifier.Peek().id != LeaseID(1) {
t.Fatalf("first item expected lease ID %d, got %d", LeaseID(1), le.leaseExpiredNotifier.Peek().id)
}
existExpiredEvent := func() {
@ -60,8 +60,8 @@ func TestLeaseQueue(t *testing.T) {
t.Fatalf("expected the expired lease to be pushed back to the heap, heap size got %d", le.leaseExpiredNotifier.Len())
}
if le.leaseExpiredNotifier.Poll().id != LeaseID(1) {
t.Fatalf("first item expected lease ID %d, got %d", LeaseID(1), le.leaseExpiredNotifier.Poll().id)
if le.leaseExpiredNotifier.Peek().id != LeaseID(1) {
t.Fatalf("first item expected lease ID %d, got %d", LeaseID(1), le.leaseExpiredNotifier.Peek().id)
}
}

View File

@ -683,7 +683,7 @@ func (le *lessor) expireExists() (l *Lease, ok bool, next bool) {
return nil, false, false
}
item := le.leaseExpiredNotifier.Poll()
item := le.leaseExpiredNotifier.Peek()
l = le.leaseMap[item.id]
if l == nil {
// lease has expired or been revoked