From a897fa04d55ca29eecc3a809cf7678e4c37e2567 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 14 May 2015 22:25:26 -0700 Subject: [PATCH] store: Watch/WatchTree: Removed unused params Signed-off-by: Andrea Luzzardi --- discovery/kv/kv.go | 2 +- pkg/store/consul.go | 10 ++++------ pkg/store/etcd.go | 4 ++-- pkg/store/store.go | 10 +++------- pkg/store/zookeeper.go | 4 ++-- 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/discovery/kv/kv.go b/discovery/kv/kv.go index ac95eeb5b3..e58553140e 100644 --- a/discovery/kv/kv.go +++ b/discovery/kv/kv.go @@ -71,7 +71,7 @@ func (s *Discovery) Fetch() ([]*discovery.Entry, error) { // Watch is exported func (s *Discovery) Watch(callback discovery.WatchCallback) { - s.store.WatchTree(s.prefix, "", s.heartbeat, func(kv ...*store.KVPair) { + s.store.WatchTree(s.prefix, func(kv ...*store.KVPair) { // Traduce byte array entries to discovery.Entry entries, _ := discovery.CreateEntries(convertToStringArray(kv)) callback(entries) diff --git a/pkg/store/consul.go b/pkg/store/consul.go index 8af94a0e37..1078af3e58 100644 --- a/pkg/store/consul.go +++ b/pkg/store/consul.go @@ -25,7 +25,6 @@ type consulLock struct { // refresh interval type Watch struct { LastIndex uint64 - Interval time.Duration } // InitializeConsul creates a new Consul client given @@ -143,7 +142,7 @@ func (s *Consul) DeleteTree(prefix string) error { } // Watch a single key for modifications -func (s *Consul) Watch(key string, heartbeat time.Duration, callback WatchCallback) error { +func (s *Consul) Watch(key string, callback WatchCallback) error { fkey := s.normalize(key) // We get the last index first @@ -153,7 +152,7 @@ func (s *Consul) Watch(key string, heartbeat time.Duration, callback WatchCallba } // Add watch to map - s.watches[fkey] = &Watch{LastIndex: meta.LastIndex, Interval: heartbeat} + s.watches[fkey] = &Watch{LastIndex: meta.LastIndex} eventChan := s.waitForChange(fkey) for _ = range eventChan { @@ -195,7 +194,6 @@ func (s *Consul) waitForChange(key string) <-chan uint64 { } option := &api.QueryOptions{ WaitIndex: watch.LastIndex, - WaitTime: watch.Interval, } _, meta, err := kv.List(key, option) if err != nil { @@ -211,7 +209,7 @@ func (s *Consul) waitForChange(key string) <-chan uint64 { } // WatchRange triggers a watch on a range of values at "directory" -func (s *Consul) WatchTree(prefix string, filter string, heartbeat time.Duration, callback WatchCallback) error { +func (s *Consul) WatchTree(prefix string, callback WatchCallback) error { fprefix := s.normalize(prefix) // We get the last index first @@ -221,7 +219,7 @@ func (s *Consul) WatchTree(prefix string, filter string, heartbeat time.Duration } // Add watch to map - s.watches[fprefix] = &Watch{LastIndex: meta.LastIndex, Interval: heartbeat} + s.watches[fprefix] = &Watch{LastIndex: meta.LastIndex} eventChan := s.waitForChange(fprefix) for _ = range eventChan { diff --git a/pkg/store/etcd.go b/pkg/store/etcd.go index 957f943644..29b4a5e887 100644 --- a/pkg/store/etcd.go +++ b/pkg/store/etcd.go @@ -136,7 +136,7 @@ func (s *Etcd) Exists(key string) (bool, error) { } // Watch a single key for modifications -func (s *Etcd) Watch(key string, _ time.Duration, callback WatchCallback) error { +func (s *Etcd) Watch(key string, callback WatchCallback) error { key = normalize(key) watchChan := make(chan *etcd.Response) stopChan := make(chan bool) @@ -216,7 +216,7 @@ func (s *Etcd) DeleteTree(prefix string) error { } // WatchRange triggers a watch on a range of values at "directory" -func (s *Etcd) WatchTree(prefix string, filter string, _ time.Duration, callback WatchCallback) error { +func (s *Etcd) WatchTree(prefix string, callback WatchCallback) error { prefix = normalize(prefix) watchChan := make(chan *etcd.Response) stopChan := make(chan bool) diff --git a/pkg/store/store.go b/pkg/store/store.go index a744e00404..d35ffaa0b4 100644 --- a/pkg/store/store.go +++ b/pkg/store/store.go @@ -1,10 +1,6 @@ package store -import ( - "time" - - log "github.com/Sirupsen/logrus" -) +import log "github.com/Sirupsen/logrus" // Backend represents a KV Store Backend type Backend string @@ -40,7 +36,7 @@ type Store interface { Exists(key string) (bool, error) // Watch changes on a key - Watch(key string, heartbeat time.Duration, callback WatchCallback) error + Watch(key string, callback WatchCallback) error // Cancel watch key CancelWatch(key string) error @@ -57,7 +53,7 @@ type Store interface { DeleteTree(prefix string) error // Watch key namespaces - WatchTree(prefix string, filter string, heartbeat time.Duration, callback WatchCallback) error + WatchTree(prefix string, callback WatchCallback) error // Cancel watch key range CancelWatchRange(prefix string) error diff --git a/pkg/store/zookeeper.go b/pkg/store/zookeeper.go index 75a391a31e..0e54b7452e 100644 --- a/pkg/store/zookeeper.go +++ b/pkg/store/zookeeper.go @@ -103,7 +103,7 @@ func (s *Zookeeper) Exists(key string) (bool, error) { } // Watch a single key for modifications -func (s *Zookeeper) Watch(key string, _ time.Duration, callback WatchCallback) error { +func (s *Zookeeper) Watch(key string, callback WatchCallback) error { fkey := normalize(key) _, _, eventChan, err := s.client.GetW(fkey) if err != nil { @@ -161,7 +161,7 @@ func (s *Zookeeper) DeleteTree(prefix string) error { } // WatchRange triggers a watch on a range of values at "directory" -func (s *Zookeeper) WatchTree(prefix string, filter string, _ time.Duration, callback WatchCallback) error { +func (s *Zookeeper) WatchTree(prefix string, callback WatchCallback) error { fprefix := normalize(prefix) _, _, eventChan, err := s.client.ChildrenW(fprefix) if err != nil {