allow consul stale

This commit is contained in:
chuckyz
2020-01-30 09:24:51 -08:00
parent e23c242d9c
commit b129bc8184

View File

@@ -13,6 +13,7 @@ import (
const (
consulNodeEnv = "CONSUL_NODE"
allowStale = "CONSUL_STALE"
matchTag = "enable_gocast"
nodeURL = "/catalog/node"
remoteHealthCheckurl = "/health/checks"
@@ -52,7 +53,11 @@ func NewConsulMon(addr string) (*ConsulMon, error) {
func (c *ConsulMon) queryServices() ([]*App, error) {
var apps []*App
addr := c.addr + fmt.Sprintf("%s/%s", nodeURL, c.node)
stale := ""
if os.Getenv(allowStale) {
stale = "?stale"
}
addr := c.addr + fmt.Sprintf("%s/%s%s", nodeURL, c.node, stale)
resp, err := c.client.Get(addr)
if err != nil {
return apps, err