Skip to content

Commit

Permalink
Merge pull request #14198 from SimFG/heap_top
Browse files Browse the repository at this point in the history
lease: Rename `Poll` to `Peek` in the `LeaseExpiredNotifier`
  • Loading branch information
ahrtr authored Jul 7, 2022
2 parents 248f072 + e586dc1 commit 186c895
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion server/lease/lease_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions server/lease/lease_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion server/lease/lessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 186c895

Please sign in to comment.