|
|
@@ -77,8 +77,6 @@ const (
|
|
|
// defaultTTL is the assumed lease TTL used for the first keepalive
|
|
|
// deadline before the actual TTL is known to the client.
|
|
|
defaultTTL = 5 * time.Second
|
|
|
- // a small buffer to store unsent lease responses.
|
|
|
- leaseResponseChSize = 16
|
|
|
// NoLease is a lease ID for the absence of a lease.
|
|
|
NoLease LeaseID = 0
|
|
|
|
|
|
@@ -86,6 +84,11 @@ const (
|
|
|
retryConnWait = 500 * time.Millisecond
|
|
|
)
|
|
|
|
|
|
+// LeaseResponseChSize is the size of buffer to store unsent lease responses.
|
|
|
+// WARNING: DO NOT UPDATE.
|
|
|
+// Only for testing purposes.
|
|
|
+var LeaseResponseChSize = 16
|
|
|
+
|
|
|
// ErrKeepAliveHalted is returned if client keep alive loop halts with an unexpected error.
|
|
|
//
|
|
|
// This usually means that automatic lease renewal via KeepAlive is broken, but KeepAliveOnce will still work as expected.
|
|
|
@@ -258,7 +261,7 @@ func (l *lessor) Leases(ctx context.Context) (*LeaseLeasesResponse, error) {
|
|
|
}
|
|
|
|
|
|
func (l *lessor) KeepAlive(ctx context.Context, id LeaseID) (<-chan *LeaseKeepAliveResponse, error) {
|
|
|
- ch := make(chan *LeaseKeepAliveResponse, leaseResponseChSize)
|
|
|
+ ch := make(chan *LeaseKeepAliveResponse, LeaseResponseChSize)
|
|
|
|
|
|
l.mu.Lock()
|
|
|
// ensure that recvKeepAliveLoop is still running
|
|
|
@@ -514,9 +517,10 @@ func (l *lessor) recvKeepAlive(resp *pb.LeaseKeepAliveResponse) {
|
|
|
for _, ch := range ka.chs {
|
|
|
select {
|
|
|
case ch <- karesp:
|
|
|
- ka.nextKeepAlive = nextKeepAlive
|
|
|
default:
|
|
|
}
|
|
|
+ // still advance in order to rate-limit keep-alive sends
|
|
|
+ ka.nextKeepAlive = nextKeepAlive
|
|
|
}
|
|
|
}
|
|
|
|