From b129bc8184dcd2eb829fa017703f055458abdc71 Mon Sep 17 00:00:00 2001 From: chuckyz Date: Thu, 30 Jan 2020 09:24:51 -0800 Subject: [PATCH] allow consul stale --- controller/consul.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/controller/consul.go b/controller/consul.go index 85a277f..ac54e50 100644 --- a/controller/consul.go +++ b/controller/consul.go @@ -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