本文整理汇总了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())
示例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()
示例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{}
})
示例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() {
示例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)