lease/lessor.go
func (le *lessor) expireExists() (l *Lease, ok bool, next bool) {
	if le.leaseHeap.Len() == 0 {
		return nil, false, false
	}

	item := le.leaseHeap[0]
	l = le.leaseMap[item.id]
	if l == nil {
		// lease has expired or been revoked
		// no need to revoke (nothing is expiry)
		heap.Pop(&le.leaseHeap) // O(log N)
		return nil, false, true
	}

	if time.Now().UnixNano() < item.time /* expiration time */ {
		// Candidate expirations are caught up, reinsert this item
		// and no need to revoke (nothing is expiry)
		return l, false, false
	}
	// if the lease is actually expired, add to the removal list. If it is not expired, we can ignore it because another entry will have been inserted into the heap

	heap.Pop(&le.leaseHeap) // O(log N)
	return l, true, false
}
func (le *lessor) expireExists() (l *Lease, ok bool, next bool) {
	if le.leaseHeap.Len() == 0 {
		return nil, false, false
	}

	item := le.leaseHeap[0]
	l = le.leaseMap[item.id]
	if l == nil {
		// lease has expired or been revoked
		// no need to revoke (nothing is expiry)
		heap.Pop(&le.leaseHeap) // O(log N)
		return nil, false, true
	}

	if time.Now().UnixNano() < item.time /* expiration time */ {
		// Candidate expirations are caught up, reinsert this item
		// and no need to revoke (nothing is expiry)
		return l, false, false
	}
	// if the lease is actually expired, add to the removal list. If it is not expired, we can ignore it because another entry will have been inserted into the heap

	heap.Pop(&le.leaseHeap) // O(log N)
	return l, true, false
}
func ( le * lessor ) expireExists ( ) ( l * Lease , ok bool , next bool ) { if le . leaseHeap . Len ( ) == 0 { return nil , false , false } item := le . leaseHeap [ 0 ] l = le . leaseMap [ item . id ] if l == nil { // lease has expired or been revoked // no need to revoke (nothing is expiry) heap . Pop ( & le . leaseHeap ) // O(log N) return nil , false , true } if time . Now ( ) . UnixNano ( ) < item . time /* expiration time */ { // Candidate expirations are caught up, reinsert this item // and no need to revoke (nothing is expiry) return l , false , false } // if the lease is actually expired, add to the removal list. If it is not expired, we can ignore it because another entry will have been inserted into the heap heap . Pop ( & le . leaseHeap ) // O(log N) return l , true , false }
// expireExists returns true if expiry items exist.
// It pops only when expiry item exists.
// "next" is true, to indicate that it may exist in next attempt.
expireExists returns true if expiry items exist . It pops only when expiry item exists . next is true to indicate that it may exist in next attempt .