// etcdWatch calls etcd's Watch function, and handles any errors. Meant to be called // as a goroutine. func (w *etcdWatcher) etcdWatch(client tools.EtcdClient, key string, resourceVersion uint64) { // glog.Infof("Watching") defer util.HandleCrash() defer close(w.etcdError) if resourceVersion == 0 { latest, err := etcdGetInitialWatchState(client, key, w.list, w.etcdIncoming) if err != nil { if etcdError, ok := err.(*etcd.EtcdError); ok && etcdError != nil && etcdError.ErrorCode == tools.EtcdErrorCodeNotFound { // glog.Errorf("Error getting initial watch, key not found: %v", err) return } glog.Errorf("Error getting initial watch: %v", err) w.etcdError <- err return } resourceVersion = latest + 1 } response, err := client.Watch(key, resourceVersion, w.list, w.etcdIncoming, w.etcdStop) glog.Infof("response is %v", response) if err != nil && err != etcd.ErrWatchStoppedByUser { glog.Errorf("Error watch: %v", err) w.etcdError <- err } }
// etcdWatch calls etcd's Watch function, and handles any errors. Meant to be called // as a goroutine. func (w *etcdWatcher) etcdWatch(client tools.EtcdClient, key string, resourceVersion uint64) { defer util.HandleCrash() defer close(w.etcdError) if resourceVersion == 0 { latest, err := etcdGetInitialWatchState(client, key, w.list, w.etcdIncoming) if err != nil { w.etcdError <- err return } resourceVersion = latest + 1 } _, err := client.Watch(key, resourceVersion, w.list, w.etcdIncoming, w.etcdStop) if err != nil && err != etcd.ErrWatchStoppedByUser { w.etcdError <- err } }