lease/lessor.go
func (le *lessor) revokeExpiredLeases() {
	var ls []*Lease

	// rate limit
	revokeLimit := leaseRevokeRate / 2

	le.mu.RLock()
	if le.isPrimary() {
		ls = le.findExpiredLeases(revokeLimit)
	}
	le.mu.RUnlock()

	if len(ls) != 0 {
		select {
		case <-le.stopC:
			return
		case le.expiredC <- ls:
		default:
			// the receiver of expiredC is probably busy handling
			// other stuff
			// let's try this next time after 500ms
		}
	}
}
func (le *lessor) revokeExpiredLeases() {
	var ls []*Lease

	// rate limit
	revokeLimit := leaseRevokeRate / 2

	le.mu.RLock()
	if le.isPrimary() {
		ls = le.findExpiredLeases(revokeLimit)
	}
	le.mu.RUnlock()

	if len(ls) != 0 {
		select {
		case <-le.stopC:
			return
		case le.expiredC <- ls:
		default:
			// the receiver of expiredC is probably busy handling
			// other stuff
			// let's try this next time after 500ms
		}
	}
}
func ( le * lessor ) revokeExpiredLeases ( ) { var ls [ ] * Lease // rate limit revokeLimit := leaseRevokeRate / 2 le . mu . RLock ( ) if le . isPrimary ( ) { ls = le . findExpiredLeases ( revokeLimit ) } le . mu . RUnlock ( ) if len ( ls ) != 0 { select { case <- le . stopC : return case le . expiredC <- ls : default : // the receiver of expiredC is probably busy handling // other stuff // let's try this next time after 500ms } } }
// revokeExpiredLeases finds all leases past their expiry and sends them to epxired channel for
// to be revoked.
revokeExpiredLeases finds all leases past their expiry and sends them to epxired channel for to be revoked .