本文整理汇总了Golang中github.com/cloudfoundry/hm9000/store.Store.GetDesiredState方法的典型用法代码示例。如果您正苦于以下问题:Golang Store.GetDesiredState方法的具体用法?Golang Store.GetDesiredState怎么用?Golang Store.GetDesiredState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/hm9000/store.Store
的用法示例。
在下文中一共展示了Store.GetDesiredState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例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))
})
It("bumps the freshness", func() {
Eventually(func() error {
_, err := storeAdapter.Get("/hm/v1" + conf.DesiredFreshnessKey)
return err
}, 1, 0.1).ShouldNot(HaveOccurred())
})
示例2:
a1.AppGuid: a1.DesiredState(1),
a2.AppGuid: a2.DesiredState(1),
stoppedApp.AppGuid: stoppedDesiredState,
pendingStagingApp.AppGuid: pendingStagingDesiredState,
failedToStageApp.AppGuid: failedStagingDesiredState,
},
BulkToken: BulkToken{
Id: 5,
},
}
httpClient.LastRequest().Succeed(response.ToJSON())
})
It("should not store the desired state (yet)", func() {
desired, _ := store.GetDesiredState()
Ω(desired).Should(HaveLen(1))
Ω(desired[deletedApp.DesiredState(1).StoreKey()]).Should(EqualDesiredState(deletedApp.DesiredState(1)))
})
It("should request the next batch", func() {
Ω(httpClient.Requests).Should(HaveLen(2))
Ω(httpClient.LastRequest().URL.Query().Get("bulk_token")).Should(Equal(response.BulkTokenRepresentation()))
})
It("should not bump the freshness yet", func() {
fresh, _ := store.IsDesiredStateFresh()
Ω(fresh).Should(BeFalse())
})
It("should not send a result down the resultChan yet", func() {