mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
fix unexpose todo
Signed-off-by: ls-2018 <acejilam@gmail.com>
This commit is contained in:
parent
ad03f2076a
commit
5b84b30fce
@ -744,7 +744,7 @@ func (le *lessor) scheduleCheckpointIfNeeded(lease *Lease) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if lease.RemainingTTL() > int64(le.checkpointInterval.Seconds()) {
|
if lease.getRemainingTTL() > int64(le.checkpointInterval.Seconds()) {
|
||||||
if le.lg != nil {
|
if le.lg != nil {
|
||||||
le.lg.Debug("Scheduling lease checkpoint",
|
le.lg.Debug("Scheduling lease checkpoint",
|
||||||
zap.Int64("leaseID", int64(lease.ID)),
|
zap.Int64("leaseID", int64(lease.ID)),
|
||||||
@ -856,8 +856,7 @@ func (l *Lease) TTL() int64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RemainingTTL returns the last checkpointed remaining TTL of the lease.
|
// RemainingTTL returns the last checkpointed remaining TTL of the lease.
|
||||||
// TODO(jpbetz): do not expose this utility method
|
func (l *Lease) getRemainingTTL() int64 {
|
||||||
func (l *Lease) RemainingTTL() int64 {
|
|
||||||
if l.remainingTTL > 0 {
|
if l.remainingTTL > 0 {
|
||||||
return l.remainingTTL
|
return l.remainingTTL
|
||||||
}
|
}
|
||||||
@ -866,7 +865,7 @@ func (l *Lease) RemainingTTL() int64 {
|
|||||||
|
|
||||||
// refresh refreshes the expiry of the lease.
|
// refresh refreshes the expiry of the lease.
|
||||||
func (l *Lease) refresh(extend time.Duration) {
|
func (l *Lease) refresh(extend time.Duration) {
|
||||||
newExpiry := time.Now().Add(extend + time.Duration(l.RemainingTTL())*time.Second)
|
newExpiry := time.Now().Add(extend + time.Duration(l.getRemainingTTL())*time.Second)
|
||||||
l.expiryMu.Lock()
|
l.expiryMu.Lock()
|
||||||
defer l.expiryMu.Unlock()
|
defer l.expiryMu.Unlock()
|
||||||
l.expiry = newExpiry
|
l.expiry = newExpiry
|
||||||
|
@ -634,18 +634,18 @@ func TestLessorCheckpointPersistenceAfterRestart(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if l.RemainingTTL() != ttl {
|
if l.getRemainingTTL() != ttl {
|
||||||
t.Errorf("remainingTTL() = %d, expected: %d", l.RemainingTTL(), ttl)
|
t.Errorf("getRemainingTTL() = %d, expected: %d", l.getRemainingTTL(), ttl)
|
||||||
}
|
}
|
||||||
le.Checkpoint(2, checkpointTTL)
|
le.Checkpoint(2, checkpointTTL)
|
||||||
if l.RemainingTTL() != checkpointTTL {
|
if l.getRemainingTTL() != checkpointTTL {
|
||||||
t.Errorf("remainingTTL() = %d, expected: %d", l.RemainingTTL(), checkpointTTL)
|
t.Errorf("getRemainingTTL() = %d, expected: %d", l.getRemainingTTL(), checkpointTTL)
|
||||||
}
|
}
|
||||||
le.Stop()
|
le.Stop()
|
||||||
le2 := newLessor(lg, be, clusterLatest(), cfg)
|
le2 := newLessor(lg, be, clusterLatest(), cfg)
|
||||||
l = le2.Lookup(2)
|
l = le2.Lookup(2)
|
||||||
if l.RemainingTTL() != tc.expectRemainingTTL {
|
if l.getRemainingTTL() != tc.expectRemainingTTL {
|
||||||
t.Errorf("remainingTTL() = %d, expected: %d", l.RemainingTTL(), tc.expectRemainingTTL)
|
t.Errorf("getRemainingTTL() = %d, expected: %d", l.getRemainingTTL(), tc.expectRemainingTTL)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user