Merge pull request #14198 from SimFG/heap_top

lease: Rename `Poll` to `Peek` in the `LeaseExpiredNotifier`
This commit is contained in:
Benjamin Wang 2022-07-08 04:59:43 +08:00 committed by GitHub
commit 186c895da8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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