Browse Source

lease: godoc "LeaseWithTime", change field name to "id"

No need to have "lease" in field name.

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Gyuho Lee 7 years ago
parent
commit
51b8d68a7f
2 changed files with 7 additions and 6 deletions
  1. 2 1
      lease/lease_queue.go
  2. 5 5
      lease/lessor.go

+ 2 - 1
lease/lease_queue.go

@@ -14,8 +14,9 @@
 
 
 package lease
 package lease
 
 
+// LeaseWithTime contains lease object with expire information.
 type LeaseWithTime struct {
 type LeaseWithTime struct {
-	leaseId    LeaseID
+	id         LeaseID
 	expiration int64
 	expiration int64
 	index      int
 	index      int
 }
 }

+ 5 - 5
lease/lessor.go

@@ -235,7 +235,7 @@ func (le *lessor) Grant(id LeaseID, ttl int64) (*Lease, error) {
 	}
 	}
 
 
 	le.leaseMap[id] = l
 	le.leaseMap[id] = l
-	item := &LeaseWithTime{leaseId: l.ID, expiration: l.expiry.UnixNano()}
+	item := &LeaseWithTime{id: l.ID, expiration: l.expiry.UnixNano()}
 	heap.Push(&le.leaseHeap, item)
 	heap.Push(&le.leaseHeap, item)
 	l.persistTo(le.b)
 	l.persistTo(le.b)
 
 
@@ -319,7 +319,7 @@ func (le *lessor) Renew(id LeaseID) (int64, error) {
 	}
 	}
 
 
 	l.refresh(0)
 	l.refresh(0)
-	item := &LeaseWithTime{leaseId: l.ID, expiration: l.expiry.UnixNano()}
+	item := &LeaseWithTime{id: l.ID, expiration: l.expiry.UnixNano()}
 	heap.Push(&le.leaseHeap, item)
 	heap.Push(&le.leaseHeap, item)
 	return l.ttl, nil
 	return l.ttl, nil
 }
 }
@@ -355,7 +355,7 @@ func (le *lessor) Promote(extend time.Duration) {
 	// refresh the expiries of all leases.
 	// refresh the expiries of all leases.
 	for _, l := range le.leaseMap {
 	for _, l := range le.leaseMap {
 		l.refresh(extend)
 		l.refresh(extend)
-		item := &LeaseWithTime{leaseId: l.ID, expiration: l.expiry.UnixNano()}
+		item := &LeaseWithTime{id: l.ID, expiration: l.expiry.UnixNano()}
 		heap.Push(&le.leaseHeap, item)
 		heap.Push(&le.leaseHeap, item)
 	}
 	}
 
 
@@ -392,7 +392,7 @@ func (le *lessor) Promote(extend time.Duration) {
 		delay := time.Duration(rateDelay)
 		delay := time.Duration(rateDelay)
 		nextWindow = baseWindow + delay
 		nextWindow = baseWindow + delay
 		l.refresh(delay + extend)
 		l.refresh(delay + extend)
-		item := &LeaseWithTime{leaseId: l.ID, expiration: l.expiry.UnixNano()}
+		item := &LeaseWithTime{id: l.ID, expiration: l.expiry.UnixNano()}
 		heap.Push(&le.leaseHeap, item)
 		heap.Push(&le.leaseHeap, item)
 	}
 	}
 }
 }
@@ -532,7 +532,7 @@ func (le *lessor) findExpiredLeases(limit int) []*Lease {
 		}
 		}
 
 
 		item := heap.Pop(&le.leaseHeap).(*LeaseWithTime)
 		item := heap.Pop(&le.leaseHeap).(*LeaseWithTime)
-		l := le.leaseMap[item.leaseId]
+		l := le.leaseMap[item.id]
 		if l == nil {
 		if l == nil {
 			// lease has expired or been revoked, continue
 			// lease has expired or been revoked, continue
 			continue
 			continue