本文整理汇总了Golang中github.com/cloudfoundry/hm9000/config.Config.FetcherNetworkTimeout方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.FetcherNetworkTimeout方法的具体用法?Golang Config.FetcherNetworkTimeout怎么用?Golang Config.FetcherNetworkTimeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/hm9000/config.Config
的用法示例。
在下文中一共展示了Config.FetcherNetworkTimeout方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: fetchDesiredState
func fetchDesiredState(l logger.Logger, conf *config.Config, store store.Store) error {
l.Info("Fetching Desired State")
fetcher := desiredstatefetcher.New(conf,
store,
metricsaccountant.New(store),
httpclient.NewHttpClient(conf.SkipSSLVerification, conf.FetcherNetworkTimeout()),
buildTimeProvider(l),
l,
)
resultChan := make(chan desiredstatefetcher.DesiredStateFetcherResult, 1)
fetcher.Fetch(resultChan)
result := <-resultChan
if result.Success {
l.Info("Success", map[string]string{"Number of Desired Apps Fetched": strconv.Itoa(result.NumResults)})
return nil
} else {
l.Error(result.Message, result.Error)
return result.Error
}
return nil
}
示例2:
resultChan = make(chan desiredstatefetcher.DesiredStateFetcherResult, 1)
a1 = appfixture.NewAppFixture()
a2 = appfixture.NewAppFixture()
a3 = appfixture.NewAppFixture()
stateServer.SetDesiredState([]models.DesiredAppState{
a1.DesiredState(1),
a2.DesiredState(1),
a3.DesiredState(1),
})
conf, _ = config.DefaultConfig()
store = storepackage.NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())
fetcher = desiredstatefetcher.New(conf, store, fakemetricsaccountant.New(), httpclient.NewHttpClient(conf.SkipSSLVerification, conf.FetcherNetworkTimeout()), &timeprovider.RealTimeProvider{}, fakelogger.NewFakeLogger())
fetcher.Fetch(resultChan)
})
It("requests for the first set of data from the CC and stores the response", func() {
var desired map[string]models.DesiredAppState
var err error
Eventually(func() interface{} {
desired, err = store.GetDesiredState()
return desired
}, 1, 0.1).ShouldNot(BeEmpty())
Ω(desired).Should(HaveKey(a1.AppGuid + "," + a1.AppVersion))
Ω(desired).Should(HaveKey(a2.AppGuid + "," + a2.AppVersion))
Ω(desired).Should(HaveKey(a3.AppGuid + "," + a3.AppVersion))
})
示例3:
resultChan = make(chan desiredstatefetcher.DesiredStateFetcherResult, 1)
a1 = appfixture.NewAppFixture()
a2 = appfixture.NewAppFixture()
a3 = appfixture.NewAppFixture()
stateServer.SetDesiredState([]models.DesiredAppState{
a1.DesiredState(1),
a2.DesiredState(1),
a3.DesiredState(1),
})
conf, _ = config.DefaultConfig()
store = storepackage.NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())
fetcher = desiredstatefetcher.New(conf, store, &fakemetricsaccountant.FakeMetricsAccountant{}, httpclient.NewHttpClient(conf.SkipSSLVerification, conf.FetcherNetworkTimeout()), clock.NewClock(), fakelogger.NewFakeLogger())
fetcher.Fetch(resultChan)
})
It("requests for the first set of data from the CC and stores the response", func() {
var desired map[string]models.DesiredAppState
var err error
Eventually(func() interface{} {
desired, err = store.GetDesiredState()
return desired
}, 1, 0.1).ShouldNot(BeEmpty())
Ω(desired).Should(HaveKey(a1.AppGuid + "," + a1.AppVersion))
Ω(desired).Should(HaveKey(a2.AppGuid + "," + a2.AppVersion))
Ω(desired).Should(HaveKey(a3.AppGuid + "," + a3.AppVersion))
})