diff --git a/discovery/kv/kv.go b/discovery/kv/kv.go index a413aec462..c43efaaad5 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.WatchRange(s.prefix, "", s.heartbeat, func(kvalues []store.KVEntry) { + s.store.WatchRange(s.prefix, "", s.heartbeat, func(kvalues ...store.KVEntry) { // Traduce byte array entries to discovery.Entry entries, _ := discovery.CreateEntries(convertToStringArray(kvalues)) callback(entries) diff --git a/pkg/store/consul.go b/pkg/store/consul.go index 536dd8e070..cf6dd1017a 100644 --- a/pkg/store/consul.go +++ b/pkg/store/consul.go @@ -160,9 +160,7 @@ func (s *Consul) Watch(key string, heartbeat time.Duration, callback WatchCallba s.watches[fkey] = nil return err } - - value := []KVEntry{&kviTuple{key, entry, index}} - callback(value) + callback(&kviTuple{key, entry, index}) } return nil @@ -230,7 +228,7 @@ func (s *Consul) WatchRange(prefix string, filter string, heartbeat time.Duratio s.watches[fprefix] = nil return err } - callback(kvi) + callback(kvi...) } return nil diff --git a/pkg/store/etcd.go b/pkg/store/etcd.go index 33689445bb..7b53c38ae7 100644 --- a/pkg/store/etcd.go +++ b/pkg/store/etcd.go @@ -153,8 +153,7 @@ func (s *Etcd) Watch(key string, _ time.Duration, callback WatchCallback) error s.watches[key] = nil return err } - kvi := []KVEntry{&kviTuple{key, entry, index}} - callback(kvi) + callback(&kviTuple{key, entry, index}) } return nil } @@ -242,7 +241,7 @@ func (s *Etcd) WatchRange(prefix string, filter string, _ time.Duration, callbac s.watches[prefix] = nil return err } - callback(kvi) + callback(kvi...) } return nil } diff --git a/pkg/store/store.go b/pkg/store/store.go index 7a405a69be..b699bd08de 100644 --- a/pkg/store/store.go +++ b/pkg/store/store.go @@ -8,7 +8,7 @@ import ( // WatchCallback is used for watch methods on keys // and is triggered on key change -type WatchCallback func(kviTuple []KVEntry) +type WatchCallback func(kviTuple ...KVEntry) // Initialize creates a new Store object, initializing the client type Initialize func(addrs []string, options Config) (Store, error) diff --git a/pkg/store/zookeeper.go b/pkg/store/zookeeper.go index b456507bb5..d25d35f306 100644 --- a/pkg/store/zookeeper.go +++ b/pkg/store/zookeeper.go @@ -113,9 +113,8 @@ func (s *Zookeeper) Watch(key string, _ time.Duration, callback WatchCallback) e if e.Type == zk.EventNodeChildrenChanged { log.WithField("name", "zk").Debug("Discovery watch triggered") entry, index, err := s.Get(key) - kvi := []KVEntry{&kviTuple{key, []byte(entry), index}} if err == nil { - callback(kvi) + callback(&kviTuple{key, []byte(entry), index}) } } } @@ -172,7 +171,7 @@ func (s *Zookeeper) WatchRange(prefix string, filter string, _ time.Duration, ca log.WithField("name", "zk").Debug("Discovery watch triggered") kvi, err := s.GetRange(prefix) if err == nil { - callback(kvi) + callback(kvi...) } } }