本文整理匯總了Golang中github.com/eBay/fabio/_third_party/github.com/hashicorp/consul/api.Client.Health方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.Health方法的具體用法?Golang Client.Health怎麽用?Golang Client.Health使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/eBay/fabio/_third_party/github.com/hashicorp/consul/api.Client
的用法示例。
在下文中一共展示了Client.Health方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: watchAutoConfig
// watchAutoConfig monitors the consul health checks and creates a new configuration
// on every change.
func watchAutoConfig(client *api.Client, tagPrefix string, config chan []string) {
var lastIndex uint64
for {
q := &api.QueryOptions{RequireConsistent: true, WaitIndex: lastIndex}
checks, meta, err := client.Health().State("passing", q)
if err != nil {
log.Printf("[WARN] Error fetching health state. %v", err)
time.Sleep(time.Second)
continue
}
log.Printf("[INFO] Health changed to #%d", meta.LastIndex)
config <- servicesConfig(client, checks, tagPrefix)
lastIndex = meta.LastIndex
}
}