store: Watch/WatchTree: Removed unused params

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2015-05-14 22:25:26 -07:00
parent 2c1040971a
commit a897fa04d5
5 changed files with 12 additions and 18 deletions

View File

@ -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)

View File

@ -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 {

View File

@ -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)

View File

@ -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

View File

@ -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 {