当前位置: 首页>>代码示例>>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;未经允许,请勿转载。