Merge pull request #4 from chuckyz/allow_consul_stale
Allow stale requests from Consul
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
consulNodeEnv = "CONSUL_NODE"
|
consulNodeEnv = "CONSUL_NODE"
|
||||||
|
allowStale = "CONSUL_STALE"
|
||||||
matchTag = "enable_gocast"
|
matchTag = "enable_gocast"
|
||||||
nodeURL = "/catalog/node"
|
nodeURL = "/catalog/node"
|
||||||
remoteHealthCheckurl = "/health/checks"
|
remoteHealthCheckurl = "/health/checks"
|
||||||
@@ -52,7 +53,11 @@ func NewConsulMon(addr string) (*ConsulMon, error) {
|
|||||||
|
|
||||||
func (c *ConsulMon) queryServices() ([]*App, error) {
|
func (c *ConsulMon) queryServices() ([]*App, error) {
|
||||||
var apps []*App
|
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)
|
resp, err := c.client.Get(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return apps, err
|
return apps, err
|
||||||
|
|||||||
Reference in New Issue
Block a user