Skip to content

Commit

Permalink
Merge pull request #4 from chuckyz/allow_consul_stale
Browse files Browse the repository at this point in the history
Allow stale requests from Consul
  • Loading branch information
mayuresh82 authored Jan 31, 2020
2 parents e23c242 + 4a9df03 commit 8a26f23
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion controller/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

const (
consulNodeEnv = "CONSUL_NODE"
allowStale = "CONSUL_STALE"
matchTag = "enable_gocast"
nodeURL = "/catalog/node"
remoteHealthCheckurl = "/health/checks"
Expand Down Expand Up @@ -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)
var stale string
if os.Getenv(allowStale) == "true" {
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
Expand Down

0 comments on commit 8a26f23

Please sign in to comment.