Browse Source

clientv3: typedef <-chan WatchResponse to WatchChan

Anthony Romano 10 years ago
parent
commit
2415303991
2 changed files with 9 additions and 7 deletions
  1. 1 1
      clientv3/integration/watch_test.go
  2. 8 6
      clientv3/watch.go

+ 1 - 1
clientv3/integration/watch_test.go

@@ -35,7 +35,7 @@ type watchctx struct {
 	w       clientv3.Watcher
 	wclient *clientv3.Client
 	kv      clientv3.KV
-	ch      <-chan clientv3.WatchResponse
+	ch      clientv3.WatchChan
 }
 
 func runWatchTest(t *testing.T, f watcherTest) {

+ 8 - 6
clientv3/watch.go

@@ -24,18 +24,20 @@ import (
 	storagepb "github.com/coreos/etcd/storage/storagepb"
 )
 
+type WatchChan <-chan WatchResponse
+
 type Watcher interface {
 	// Watch watches on a single key. The watched events will be returned
 	// through the returned channel.
 	// If the watch is slow or the required rev is compacted, the watch request
 	// might be canceled from the server-side and the chan will be closed.
-	Watch(cxt context.Context, key string, rev int64) <-chan WatchResponse
+	Watch(ctx context.Context, key string, rev int64) WatchChan
 
-	// Watch watches on a prefix. The watched events will be returned
+	// WatchPrefix watches on a prefix. The watched events will be returned
 	// through the returned channel.
 	// If the watch is slow or the required rev is compacted, the watch request
 	// might be canceled from the server-side and the chan will be closed.
-	WatchPrefix(cxt context.Context, prefix string, rev int64) <-chan WatchResponse
+	WatchPrefix(ctx context.Context, prefix string, rev int64) WatchChan
 
 	// Close closes the watcher and cancels all watch requests.
 	Close() error
@@ -125,11 +127,11 @@ func NewWatcher(c *Client) Watcher {
 	return w
 }
 
-func (w *watcher) Watch(ctx context.Context, key string, rev int64) <-chan WatchResponse {
+func (w *watcher) Watch(ctx context.Context, key string, rev int64) WatchChan {
 	return w.watch(ctx, key, "", rev)
 }
 
-func (w *watcher) WatchPrefix(ctx context.Context, prefix string, rev int64) <-chan WatchResponse {
+func (w *watcher) WatchPrefix(ctx context.Context, prefix string, rev int64) WatchChan {
 	return w.watch(ctx, "", prefix, rev)
 }
 
@@ -143,7 +145,7 @@ func (w *watcher) Close() error {
 }
 
 // watch posts a watch request to run() and waits for a new watcher channel
-func (w *watcher) watch(ctx context.Context, key, prefix string, rev int64) <-chan WatchResponse {
+func (w *watcher) watch(ctx context.Context, key, prefix string, rev int64) WatchChan {
 	retc := make(chan chan WatchResponse, 1)
 	wr := &watchRequest{ctx: ctx, key: key, prefix: prefix, rev: rev, retc: retc}
 	// submit request