當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Config.ActualFreshnessTTL方法代碼示例

本文整理匯總了Golang中github.com/cloudfoundry/hm9000/config.Config.ActualFreshnessTTL方法的典型用法代碼示例。如果您正苦於以下問題:Golang Config.ActualFreshnessTTL方法的具體用法?Golang Config.ActualFreshnessTTL怎麽用?Golang Config.ActualFreshnessTTL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cloudfoundry/hm9000/config.Config的用法示例。


在下文中一共展示了Config.ActualFreshnessTTL方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1:

					Ω(err).ShouldNot(HaveOccurred())

					Ω(value.TTL).Should(BeNumerically("==", ttl))

					var freshnessTimestamp models.FreshnessTimestamp
					json.Unmarshal(value.Value, &freshnessTimestamp)

					Ω(freshnessTimestamp.Timestamp).Should(BeNumerically("==", 100))
					Ω(value.Key).Should(Equal(key))
				})
			})
		}

		Context("the actual state", func() {
			bumpingFreshness("/hm/v1"+conf.ActualFreshnessKey, conf.ActualFreshnessTTL(), Store.BumpActualFreshness)

			Context("revoking actual state freshness", func() {
				BeforeEach(func() {
					store.BumpActualFreshness(time.Unix(100, 0))
				})

				It("should no longer be fresh", func() {
					fresh, err := store.IsActualStateFresh(time.Unix(130, 0))
					Ω(err).ShouldNot(HaveOccurred())
					Ω(fresh).Should(BeTrue())

					store.RevokeActualFreshness()

					fresh, err = store.IsActualStateFresh(time.Unix(130, 0))
					Ω(err).ShouldNot(HaveOccurred())
開發者ID:nkts,項目名稱:golang-devops-stuff,代碼行數:30,代碼來源:freshness_test.go

示例2:

		conf              *config.Config
		freshByTime       time.Time
		usageTracker      *fakeusagetracker.FakeUsageTracker
		metricsAccountant *fakemetricsaccountant.FakeMetricsAccountant
	)

	BeforeEach(func() {
		var err error
		conf, err = config.DefaultConfig()

		Ω(err).ShouldNot(HaveOccurred())

		timeProvider = faketimeprovider.New(time.Unix(100, 0))
		timeProvider.ProvideFakeChannels = true

		freshByTime = time.Unix(int64(100+conf.ActualFreshnessTTL()), 0)

		dea = NewDeaFixture()
		app = NewAppFixture()
		anotherApp = NewAppFixture()
		anotherApp.DeaGuid = app.DeaGuid

		storeAdapter = fakestoreadapter.New()
		store = storepackage.NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())
		messageBus = fakeyagnats.New()
		logger = fakelogger.NewFakeLogger()

		usageTracker = fakeusagetracker.New()
		usageTracker.UsageToReturn = 0.7
		metricsAccountant = fakemetricsaccountant.New()
開發者ID:KeyOfSpectator,項目名稱:hm9000,代碼行數:30,代碼來源:actual_state_listener_test.go

示例3:

		logger            *fakelogger.FakeLogger
		conf              *config.Config
		freshByTime       time.Time
		usageTracker      *fakemetricsaccountant.FakeUsageTracker
		metricsAccountant *fakemetricsaccountant.FakeMetricsAccountant
	)

	BeforeEach(func() {
		var err error
		conf, err = config.DefaultConfig()

		Expect(err).NotTo(HaveOccurred())

		clock = fakeclock.NewFakeClock(time.Unix(100, 0))

		freshByTime = time.Unix(int64(100+conf.ActualFreshnessTTL()), 0)

		dea = NewDeaFixture()
		app = NewAppFixture()
		anotherApp = NewAppFixture()
		anotherApp.DeaGuid = app.DeaGuid

		storeAdapter = fakestoreadapter.New()
		store = &fakestore.FakeStore{}
		messageBus = fakeyagnats.Connect()
		logger = fakelogger.NewFakeLogger()

		usageTracker = &fakemetricsaccountant.FakeUsageTracker{}
		usageTracker.MeasureUsageReturns(0.7, 0)
		metricsAccountant = &fakemetricsaccountant.FakeMetricsAccountant{}
	})
開發者ID:nagyistge,項目名稱:hm9000,代碼行數:31,代碼來源:actual_state_listener_test.go

示例4:

		timeProvider      *faketimeprovider.FakeTimeProvider
		dea               appfixture.DeaFixture
		app               appfixture.AppFixture
		conf              *config.Config
		metricsAccountant *fakemetricsaccountant.FakeMetricsAccountant
	)

	BeforeEach(func() {
		messageBus = fakeyagnats.New()
		dea = appfixture.NewDeaFixture()
		app = dea.GetApp(0)
		conf, _ = config.DefaultConfig()
		metricsAccountant = fakemetricsaccountant.New()

		timeProvider = &faketimeprovider.FakeTimeProvider{
			TimeToProvide: time.Unix(int64(10+conf.ActualFreshnessTTL()), 0),
		}

		storeAdapter = fakestoreadapter.New()
		store = storepackage.NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())
		sender = New(store, metricsAccountant, conf, messageBus, timeProvider, fakelogger.NewFakeLogger())
		store.BumpActualFreshness(time.Unix(10, 0))
		store.BumpDesiredFreshness(time.Unix(10, 0))
	})

	Context("when the sender fails to pull messages out of the start queue", func() {
		BeforeEach(func() {
			storeAdapter.ListErrInjector = fakestoreadapter.NewFakeStoreAdapterErrorInjector("start", errors.New("oops"))
		})

		It("should return an error and not send any messages", func() {
開發者ID:tomzhang,項目名稱:golang-devops-stuff,代碼行數:31,代碼來源:sender_test.go

示例5:

		messageBus        *fakeyagnats.FakeNATSConn
		timeProvider      *fakeclock.FakeClock
		dea               appfixture.DeaFixture
		app               appfixture.AppFixture
		conf              *config.Config
		metricsAccountant *fakemetricsaccountant.FakeMetricsAccountant
	)

	BeforeEach(func() {
		messageBus = fakeyagnats.Connect()
		dea = appfixture.NewDeaFixture()
		app = dea.GetApp(0)
		conf, _ = config.DefaultConfig()
		metricsAccountant = &fakemetricsaccountant.FakeMetricsAccountant{}

		timeProvider = fakeclock.NewFakeClock(time.Unix(int64(10+conf.ActualFreshnessTTL()), 0))

		storeAdapter = fakestoreadapter.New()
		store = storepackage.NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())
		sender = New(store, metricsAccountant, conf, messageBus, fakelogger.NewFakeLogger())
		store.BumpActualFreshness(time.Unix(10, 0))
		store.BumpDesiredFreshness(time.Unix(10, 0))
	})

	Context("when the sender fails to pull messages out of the start queue", func() {
		BeforeEach(func() {
			storeAdapter.ListErrInjector = fakestoreadapter.NewFakeStoreAdapterErrorInjector("start", errors.New("oops"))
		})

		It("should return an error and not send any messages", func() {
			err := sender.Send(timeProvider)
開發者ID:nagyistge,項目名稱:hm9000,代碼行數:31,代碼來源:sender_test.go


注:本文中的github.com/cloudfoundry/hm9000/config.Config.ActualFreshnessTTL方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。