Skip to content

Commit

Permalink
fixed broken etcd watch support
Browse files Browse the repository at this point in the history
  • Loading branch information
HeavyHorst committed Feb 19, 2016
1 parent 9bb4aa7 commit 7f05488
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
16 changes: 6 additions & 10 deletions backends/etcd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,15 @@ func (c *Client) WatchPrefix(prefix string, waitIndex uint64, stopChan chan bool
prefix = "/"
}

// return something > 0 to trigger a key retrieval from the store
if waitIndex == 0 {
resp, err := c.client.Get(context.Background(), prefix, &client.GetOptions{
Recursive: true,
Sort: false,
Quorum: true,
})
if err != nil {
return 0, err
}
return resp.Index, nil
return 1, nil
}

watcher := c.client.Watcher(prefix, &client.WatcherOptions{AfterIndex: waitIndex, Recursive: true})
// Setting AfterIndex to 0 (default) means that the Watcher
// should start watching for events starting at the current
// index, whatever that may be.
watcher := c.client.Watcher(prefix, &client.WatcherOptions{AfterIndex: uint64(0), Recursive: true})
ctx, cancel := context.WithCancel(context.Background())
cancelRoutine := make(chan bool)
defer close(cancelRoutine)
Expand Down
10 changes: 5 additions & 5 deletions resource/template/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ func IntervalProcessor(config Config, stopChan, doneChan chan bool, errChan chan
func (p *intervalProcessor) Process() {
defer close(p.doneChan)
for {
ts, err := getTemplateResources(p.config)
if err != nil {
log.Fatal(err.Error())
break
}
ts, err := getTemplateResources(p.config)
if err != nil {
log.Fatal(err.Error())
break
}
process(ts)
select {
case <-p.stopChan:
Expand Down

0 comments on commit 7f05488

Please sign in to comment.