Skip to content

Commit

Permalink
fix: consume the etcd keepalive channel (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
steakyan authored Jul 3, 2022
1 parent 11ac997 commit c5946d5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions store/etcd/v3/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,17 @@ func (s *EtcdV3) Put(key string, value []byte, opts *store.WriteOptions) error {
}

if opts.KeepAlive {
// We do not consume the channel here.
// Client will keep renewing the lease in the background this way.
_, err = lease.KeepAlive(context.Background(), grant.ID)
ch, err := lease.KeepAlive(context.Background(), grant.ID)
if err != nil {
return err
}
// We do not care the element in the keepalive channel
// Just eat messages from the channel
go func() {
for v := range ch {
_ = v
}
}()
}

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

0 comments on commit c5946d5

Please sign in to comment.