Skip to content

Commit 5361533

Browse files
Capture and return errors during watches on consul
Before this change consul errors were not returned correctly during watches. Resolved the issue by returning the initial watch index and error and avoid the nil pointer dereference. Fixes #322
1 parent 7afb8d6 commit 5361533

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

backends/consul/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ func (c *ConsulClient) WatchPrefix(prefix string, waitIndex uint64, stopChan cha
8383
WaitIndex: waitIndex,
8484
}
8585
_, meta, err := c.client.List(prefix, &opts)
86+
if err != nil {
87+
respChan <- watchResponse{waitIndex, err}
88+
return
89+
}
8690
respChan <- watchResponse{meta.LastIndex, err}
8791
}()
8892
for {

0 commit comments

Comments
 (0)