本文整理汇总了Golang中github.com/hashicorp/consul/api.QueryOptions.Datacenter方法的典型用法代码示例。如果您正苦于以下问题:Golang QueryOptions.Datacenter方法的具体用法?Golang QueryOptions.Datacenter怎么用?Golang QueryOptions.Datacenter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/hashicorp/consul/api.QueryOptions
的用法示例。
在下文中一共展示了QueryOptions.Datacenter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: QueryOptions
func (c *Cmd) QueryOptions() *consulapi.QueryOptions {
csl := c.consul
queryOpts := new(consulapi.QueryOptions)
if csl.token != "" {
queryOpts.Token = csl.token
}
if csl.dc != "" {
queryOpts.Datacenter = csl.dc
}
if csl.waitIndex != 0 {
queryOpts.WaitIndex = csl.waitIndex
}
if csl.consistent {
queryOpts.RequireConsistent = csl.consistent
}
if csl.stale {
queryOpts.AllowStale = csl.stale
}
return queryOpts
}
示例2: getServiceEntries
func (data *consulData) getServiceEntries(health *api.Health) (entries []*api.ServiceEntry, err error) {
options := api.QueryOptions{}
if data.dc != "" {
options.Datacenter = data.dc
}
entries, _, err = health.Service(data.serviceName, data.serviceTag, true, &options)
return entries, err
}
示例3: QueryOptions
func (m *Meta) QueryOptions() *consulapi.QueryOptions {
queryOpts := new(consulapi.QueryOptions)
if m.token != "" {
queryOpts.Token = m.token
}
if m.dc != "" {
queryOpts.Datacenter = m.dc
}
if m.waitIndex != 0 {
queryOpts.WaitIndex = m.waitIndex
}
return queryOpts
}
示例4: QueryOptions
func (m *Meta) QueryOptions() *consulapi.QueryOptions {
queryOpts := new(consulapi.QueryOptions)
if os.Getenv("CONSUL_TOKEN") != "" {
queryOpts.Token = os.Getenv("CONSUL_TOKEN")
}
if m.token != "" {
queryOpts.Token = m.token
}
if m.dc != "" {
queryOpts.Datacenter = m.dc
}
if m.waitIndex != 0 {
queryOpts.WaitIndex = m.waitIndex
}
return queryOpts
}