當前位置: 首頁>>代碼示例>>Golang>>正文


Golang RouteRegistry.Lookup方法代碼示例

本文整理匯總了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
}
開發者ID:tomzhang,項目名稱:golang-devops-stuff,代碼行數:27,代碼來源:helper_test.go

示例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
}
開發者ID:rakutentech,項目名稱:gorouter,代碼行數:10,代碼來源:helper_test.go

示例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
}
開發者ID:rakutentech,項目名稱:gorouter,代碼行數:31,代碼來源:router_test.go


注:本文中的github.com/cloudfoundry/gorouter/registry.RouteRegistry.Lookup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。