Skip to content

Commit

Permalink
Merge pull request #6413 from xiang90/fix_wait
Browse files Browse the repository at this point in the history
clientv3: return error from response when possible
  • Loading branch information
xiang90 authored Sep 13, 2016
2 parents 3df8838 + 56084a7 commit 8c492c7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion clientv3/concurrency/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ import (
func waitDelete(ctx context.Context, client *v3.Client, key string, rev int64) error {
cctx, cancel := context.WithCancel(ctx)
defer cancel()

var wr v3.WatchResponse
wch := client.Watch(cctx, key, v3.WithRev(rev))
for wr := range wch {
for wr = range wch {
for _, ev := range wr.Events {
if ev.Type == mvccpb.DELETE {
return nil
}
}
}
if err := wr.Err(); err != nil {
return err
}

if err := ctx.Err(); err != nil {
return err
}
Expand Down

0 comments on commit 8c492c7

Please sign in to comment.