本文整理匯總了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
}