本文整理汇总了Golang中github.com/cloudfoundry/gorouter/test_util.SpecConfig函数的典型用法代码示例。如果您正苦于以下问题:Golang SpecConfig函数的具体用法?Golang SpecConfig怎么用?Golang SpecConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SpecConfig函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
var mbusClient *yagnats.Client
var registry *rregistry.RouteRegistry
var varz vvarz.Varz
var router *Router
var natsPort uint16
BeforeEach(func() {
natsPort = test_util.NextAvailPort()
natsRunner = natsrunner.NewNATSRunner(int(natsPort))
natsRunner.Start()
proxyPort := test_util.NextAvailPort()
statusPort := test_util.NextAvailPort()
config = test_util.SpecConfig(natsPort, statusPort, proxyPort)
config.EndpointTimeout = 5 * time.Second
mbusClient = natsRunner.MessageBus.(*yagnats.Client)
registry = rregistry.NewRouteRegistry(config, mbusClient)
varz = vvarz.NewVarz(registry)
logcounter := vcap.NewLogCounter()
proxy := proxy.NewProxy(proxy.ProxyArgs{
EndpointTimeout: config.EndpointTimeout,
Ip: config.Ip,
TraceKey: config.TraceKey,
Registry: registry,
Reporter: varz,
AccessLogger: &access_log.NullAccessLogger{},
})
r, err := NewRouter(config, proxy, mbusClient, registry, varz, logcounter)
示例2:
ioutil.WriteFile(cfgFile, cfgBytes, os.ModePerm)
}
configDrainSetup := func(cfg *config.Config, pruneInterval, pruneThreshold int) {
// ensure the threshold is longer than the interval that we check,
// because we set the route's timestamp to time.Now() on the interval
// as part of pausing
cfg.PruneStaleDropletsIntervalInSeconds = pruneInterval
cfg.DropletStaleThresholdInSeconds = pruneThreshold
cfg.StartResponseDelayIntervalInSeconds = 1
cfg.EndpointTimeoutInSeconds = 5
cfg.DrainTimeoutInSeconds = 1
}
createConfig := func(cfgFile string, statusPort, proxyPort uint16, pruneInterval, pruneThreshold int, natsPorts ...uint16) *config.Config {
cfg := test_util.SpecConfig(statusPort, proxyPort, natsPorts...)
configDrainSetup(cfg, pruneInterval, pruneThreshold)
cfg.OAuth = config.OAuthConfig{
TokenEndpoint: "non-existent-oauth.com",
Port: 8443,
ClientName: "client-id",
ClientSecret: "client-secret",
SkipOAuthTLSVerification: true,
}
writeConfig(cfg, cfgFile)
return cfg
}