当前位置: 首页>>代码示例>>Golang>>正文


Golang Store.GetDesiredState方法代码示例

本文整理汇总了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())
	})
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:30,代码来源:desired_state_fetcher_integration_test.go

示例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() {
开发者ID:KeyOfSpectator,项目名称:hm9000,代码行数:31,代码来源:desired_state_fetcher_test.go


注:本文中的github.com/cloudfoundry/hm9000/store.Store.GetDesiredState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。