From 56084a7cc852b2d8b428aa5619b681180b2874d0 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Tue, 13 Sep 2016 11:18:21 +0800 Subject: [PATCH] clientv3: return error from response when possible --- clientv3/concurrency/key.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/clientv3/concurrency/key.go b/clientv3/concurrency/key.go index 74d495dd066..56172bd0851 100644 --- a/clientv3/concurrency/key.go +++ b/clientv3/concurrency/key.go @@ -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 }