本文整理匯總了Golang中github.com/cloudfoundry/gorouter/registry.RouteRegistry.Lookup方法的典型用法代碼示例。如果您正苦於以下問題:Golang RouteRegistry.Lookup方法的具體用法?Golang RouteRegistry.Lookup怎麽用?Golang RouteRegistry.Lookup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/gorouter/registry.RouteRegistry
的用法示例。
在下文中一共展示了RouteRegistry.Lookup方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: waitMsgReceived
func waitMsgReceived(registry *registry.RouteRegistry, app *test.TestApp, expectedToBeFound bool, timeout time.Duration) bool {
interval := time.Millisecond * 50
repetitions := int(timeout / interval)
for j := 0; j < repetitions; j++ {
if j > 0 {
time.Sleep(interval)
}
received := true
for _, url := range app.Urls() {
pool := registry.Lookup(url)
if expectedToBeFound && pool == nil {
received = false
break
} else if !expectedToBeFound && pool != nil {
received = false
break
}
}
if received {
return true
}
}
return false
}
示例2: appUnregistered
func appUnregistered(registry *registry.RouteRegistry, app *common.TestApp) bool {
for _, url := range app.Urls() {
pool := registry.Lookup(url)
if pool != nil {
return false
}
}
return true
}
示例3: readVarz
{
"dea": "dea1",
"app": "app1",
"uris": [
"test.com"
],
"host": "1.2.3.4",
"port": 65536,
"private_instance_id": "private_instance_id"
}
`))
})
It("does not add the route to the route table", func() {
// Pool.IsEmpty() is better but the pool is not intialized yet
Consistently(func() *route.Pool { return registry.Lookup("test.com") }).Should(BeZero())
})
})
})
})
func readVarz(v vvarz.Varz) map[string]interface{} {
varz_byte, err := v.MarshalJSON()
Expect(err).ToNot(HaveOccurred())
varz_data := make(map[string]interface{})
err = json.Unmarshal(varz_byte, &varz_data)
Expect(err).ToNot(HaveOccurred())
return varz_data
}