mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
clientv3: clean up variables, add response dropping warning
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
parent
f3385418bb
commit
e93fb56037
@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
|
"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
|
||||||
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
|
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
|
||||||
|
|
||||||
|
"go.uber.org/zap"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
)
|
)
|
||||||
@ -172,6 +173,8 @@ type lessor struct {
|
|||||||
firstKeepAliveOnce sync.Once
|
firstKeepAliveOnce sync.Once
|
||||||
|
|
||||||
callOpts []grpc.CallOption
|
callOpts []grpc.CallOption
|
||||||
|
|
||||||
|
lg *zap.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
// keepAlive multiplexes a keepalive for a lease over multiple channels
|
// keepAlive multiplexes a keepalive for a lease over multiple channels
|
||||||
@ -196,6 +199,7 @@ func NewLeaseFromLeaseClient(remote pb.LeaseClient, c *Client, keepAliveTimeout
|
|||||||
keepAlives: make(map[LeaseID]*keepAlive),
|
keepAlives: make(map[LeaseID]*keepAlive),
|
||||||
remote: remote,
|
remote: remote,
|
||||||
firstKeepAliveTimeout: keepAliveTimeout,
|
firstKeepAliveTimeout: keepAliveTimeout,
|
||||||
|
lg: c.lg,
|
||||||
}
|
}
|
||||||
if l.firstKeepAliveTimeout == time.Second {
|
if l.firstKeepAliveTimeout == time.Second {
|
||||||
l.firstKeepAliveTimeout = defaultTTL
|
l.firstKeepAliveTimeout = defaultTTL
|
||||||
@ -459,7 +463,6 @@ func (l *lessor) recvKeepAliveLoop() (gerr error) {
|
|||||||
|
|
||||||
select {
|
select {
|
||||||
case <-time.After(retryConnWait):
|
case <-time.After(retryConnWait):
|
||||||
continue
|
|
||||||
case <-l.stopCtx.Done():
|
case <-l.stopCtx.Done():
|
||||||
return l.stopCtx.Err()
|
return l.stopCtx.Err()
|
||||||
}
|
}
|
||||||
@ -518,6 +521,12 @@ func (l *lessor) recvKeepAlive(resp *pb.LeaseKeepAliveResponse) {
|
|||||||
select {
|
select {
|
||||||
case ch <- karesp:
|
case ch <- karesp:
|
||||||
default:
|
default:
|
||||||
|
if l.lg != nil {
|
||||||
|
l.lg.Warn("lease keepalive response queue is full; dropping response send",
|
||||||
|
zap.Int("queue-size", len(ch)),
|
||||||
|
zap.Int("queue-capacity", cap(ch)),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// still advance in order to rate-limit keep-alive sends
|
// still advance in order to rate-limit keep-alive sends
|
||||||
ka.nextKeepAlive = nextKeepAlive
|
ka.nextKeepAlive = nextKeepAlive
|
||||||
@ -569,7 +578,7 @@ func (l *lessor) sendKeepAliveLoop(stream pb.Lease_LeaseKeepAliveClient) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-time.After(500 * time.Millisecond):
|
case <-time.After(retryConnWait):
|
||||||
case <-stream.Context().Done():
|
case <-stream.Context().Done():
|
||||||
return
|
return
|
||||||
case <-l.donec:
|
case <-l.donec:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user