diff --git a/.words b/.words index 561453ce956..7ca7100bdcb 100644 --- a/.words +++ b/.words @@ -1,6 +1,8 @@ ErrCodeEnhanceYourCalm ErrTimeout GoAway +KeepAlive +Keepalive RPC RPCs TODO diff --git a/clientv3/lease.go b/clientv3/lease.go index d9059022094..229e8cd66ba 100644 --- a/clientv3/lease.go +++ b/clientv3/lease.go @@ -113,11 +113,29 @@ type Lease interface { // Leases retrieves all leases. Leases(ctx context.Context) (*LeaseLeasesResponse, error) - // KeepAlive keeps the given lease alive forever. + // KeepAlive keeps the given lease alive forever. If the keepalive response + // posted to the channel is not consumed immediately, the lease client will + // continue sending keep alive requests to the etcd server at least every + // second until latest response is consumed. + // + // The returned "LeaseKeepAliveResponse" channel closes if underlying keep + // alive stream is interrupted in some way the client cannot handle itself; + // given context "ctx" is canceled or timed out. "LeaseKeepAliveResponse" + // from this closed channel is nil. + // + // If client keep alive loop halts with an unexpected error (e.g. "etcdserver: + // no leader") or canceled by the caller (e.g. context.Canceled), the error + // is returned. Otherwise, it retries. + // + // TODO(v4.0): post errors to last keep alive message before closing + // (see https://github.com/coreos/etcd/pull/7866) KeepAlive(ctx context.Context, id LeaseID) (<-chan *LeaseKeepAliveResponse, error) - // KeepAliveOnce renews the lease once. In most of the cases, KeepAlive - // should be used instead of KeepAliveOnce. + // KeepAliveOnce renews the lease once. The response corresponds to the + // first message from calling KeepAlive. If the response has a recoverable + // error, KeepAliveOnce will retry the RPC with a new keep alive message. + // + // In most of the cases, Keepalive should be used instead of KeepAliveOnce. KeepAliveOnce(ctx context.Context, id LeaseID) (*LeaseKeepAliveResponse, error) // Close releases all resources Lease keeps for efficient communication