Skip to content

Commit c5946d5

Browse files
authored
fix: consume the etcd keepalive channel (#62)
1 parent 11ac997 commit c5946d5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

store/etcd/v3/etcd.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,17 @@ func (s *EtcdV3) Put(key string, value []byte, opts *store.WriteOptions) error {
145145
}
146146

147147
if opts.KeepAlive {
148-
// We do not consume the channel here.
149-
// Client will keep renewing the lease in the background this way.
150-
_, err = lease.KeepAlive(context.Background(), grant.ID)
148+
ch, err := lease.KeepAlive(context.Background(), grant.ID)
151149
if err != nil {
152150
return err
153151
}
152+
// We do not care the element in the keepalive channel
153+
// Just eat messages from the channel
154+
go func() {
155+
for v := range ch {
156+
_ = v
157+
}
158+
}()
154159
}
155160

156161
pr.Then(etcd.OpPut(key, string(value), etcd.WithLease(grant.ID)))

0 commit comments

Comments
 (0)