From 5f4412996d93e7ce45c955b4ba731707034f73d2 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Mon, 27 Feb 2017 17:07:13 -0800 Subject: [PATCH] clientv3: define error type for closed watcher --- clientv3/naming/grpc.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/clientv3/naming/grpc.go b/clientv3/naming/grpc.go index fa7a2aa3f..9bb92ea61 100644 --- a/clientv3/naming/grpc.go +++ b/clientv3/naming/grpc.go @@ -16,6 +16,7 @@ package naming import ( "encoding/json" + "fmt" etcd "github.com/coreos/etcd/clientv3" "golang.org/x/net/context" @@ -25,6 +26,8 @@ import ( "google.golang.org/grpc/naming" ) +var ErrWatcherClosed = fmt.Errorf("naming: watch closed") + // GRPCResolver creates a grpc.Watcher for a target to track its resolution changes. type GRPCResolver struct { // Client is an initialized etcd client. @@ -77,7 +80,7 @@ func (gw *gRPCWatcher) Next() ([]*naming.Update, error) { // process new events on target/* wr, ok := <-gw.wch if !ok { - gw.err = grpc.Errorf(codes.Unavailable, "naming: watch closed") + gw.err = grpc.Errorf(codes.Unavailable, "%s", ErrWatcherClosed) return nil, gw.err } if gw.err = wr.Err(); gw.err != nil {