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


Golang StoreAdapter.SetMulti方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry/storeadapter.StoreAdapter.SetMulti方法的典型用法代码示例。如果您正苦于以下问题:Golang StoreAdapter.SetMulti方法的具体用法?Golang StoreAdapter.SetMulti怎么用?Golang StoreAdapter.SetMulti使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry/storeadapter.StoreAdapter的用法示例。


在下文中一共展示了StoreAdapter.SetMulti方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1:

				Ω(a2.Desired).Should(BeZero())
				Ω(a2.InstanceHeartbeats).Should(HaveLen(1))
				Ω(a2.InstanceHeartbeats).Should(ContainElement(app2.InstanceAtIndex(0).Heartbeat()))
				Ω(a2.CrashCounts[0]).Should(Equal(crashCount[2]))

				a3 := apps[app3.AppGuid+","+app3.AppVersion]
				Ω(a3.Desired).Should(EqualDesiredState(app3.DesiredState(1)))
				Ω(a3.InstanceHeartbeats).Should(HaveLen(0))
				Ω(a3.CrashCounts).Should(BeEmpty())
			})
		})

		Context("when there is an empty app directory", func() {
			It("should ignore that app directory", func() {
				storeAdapter.SetMulti([]storeadapter.StoreNode{{
					Key:   "/hm/v1/apps/actual/foo-bar",
					Value: []byte("foo"),
				}})

				apps, err := store.GetApps()
				Ω(err).ShouldNot(HaveOccurred())
				Ω(apps).Should(HaveLen(3))
			})
		})
	})

	Describe("GetApp", func() {
		Context("when there are no store errors", func() {
			Context("when the app has desired and actual state", func() {
				It("should return the app", func() {
					app, err := store.GetApp(app1.AppGuid, app1.AppVersion)
					Ω(err).ShouldNot(HaveOccurred())
开发者ID:KeyOfSpectator,项目名称:hm9000,代码行数:32,代码来源:apps_test.go

示例2:

			BeforeEach(func() {
				store.BumpDesiredFreshness(time.Unix(100, 0))
			})

			It("returns that the state is fresh", func() {
				fresh, err := store.IsDesiredStateFresh()
				Ω(err).ShouldNot(HaveOccurred())
				Ω(fresh).Should(BeTrue())
			})
		})

		Context("when the store returns an error", func() {
			BeforeEach(func() {
				err := storeAdapter.SetMulti([]storeadapter.StoreNode{
					{
						Key:   "/hm/v1/desired-fresh/mwahaha",
						Value: []byte("i'm a directory...."),
					},
				})
				Ω(err).ShouldNot(HaveOccurred())
			})

			It("should return the store's error", func() {
				fresh, err := store.IsDesiredStateFresh()
				Ω(err).Should(Equal(storeadapter.ErrorNodeIsDirectory))
				Ω(fresh).Should(BeFalse())
			})
		})
	})

	Describe("Checking actual state freshness", func() {
		Context("if the freshness key is not present", func() {
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:32,代码来源:freshness_test.go

示例3:

		storeAdapter = etcdstoreadapter.NewETCDStoreAdapter(etcdRunner.NodeURLS(),
			workpool.NewWorkPool(conf.StoreMaxConcurrentRequests))
		err = storeAdapter.Connect()
		Ω(err).ShouldNot(HaveOccurred())
		store = NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())
	})

	Describe("Deleting old schema version", func() {
		BeforeEach(func() {
			storeAdapter.SetMulti([]storeadapter.StoreNode{
				{Key: "/hm/v3/delete/me", Value: []byte("abc")},
				{Key: "/hm/v16/delete/me", Value: []byte("abc")},
				{Key: "/hm/v17/leave/me/alone", Value: []byte("abc")},
				{Key: "/hm/v17/leave/me/v1/alone", Value: []byte("abc")},
				{Key: "/hm/v18/leave/me/alone", Value: []byte("abc")},
				{Key: "/hm/delete/me", Value: []byte("abc")},
				{Key: "/hm/v1ola/delete/me", Value: []byte("abc")},
				{Key: "/hm/delete/me/too", Value: []byte("abc")},
				{Key: "/hm/locks/keep", Value: []byte("abc")},
				{Key: "/other/keep", Value: []byte("abc")},
				{Key: "/foo", Value: []byte("abc")},
				{Key: "/v3/keep", Value: []byte("abc")},
			})

			err := store.Compact()
			Ω(err).ShouldNot(HaveOccurred())
		})

		It("should delete everything under older versions", func() {
			_, err := storeAdapter.Get("/hm/v3/delete/me")
			Ω(err).Should(Equal(storeadapter.ErrorKeyNotFound))
开发者ID:cgrotz,项目名称:hm9000,代码行数:31,代码来源:compact_test.go

示例4:

			Context("when an existing app has a new service (create)", func() {
				It("adds that service to the outgoing add channel", func(done Done) {
					app2Service2 := domain.AppService{AppId: app2Service1.AppId, Url: "syslog://new.example.com:12345"}
					adapter.Create(buildNode(app2Service2))

					Expect(<-outAddChan).To(Equal(app2Service2))
					assertNoDataOnChannel(outRemoveChan)

					close(done)
				})
			})

			Context("When an existing app gets a new service (update)", func() {
				It("adds that service to the outgoing add channel", func(done Done) {
					app2Service2 := domain.AppService{AppId: app2Service1.AppId, Url: "syslog://new.example.com:12345"}
					adapter.SetMulti([]storeadapter.StoreNode{buildNode(app2Service2)})

					Expect(<-outAddChan).To(Equal(app2Service2))
					assertNoDataOnChannel(outRemoveChan)

					close(done)
				})
			})

			Context("when a new app appears", func() {
				It("adds that app and its services to the outgoing add channel", func(done Done) {
					app3Service1 := domain.AppService{AppId: "app-3", Url: "syslog://app3.example.com:12345"}
					app3Service2 := domain.AppService{AppId: "app-3", Url: "syslog://app3.example.com:12346"}

					adapter.Create(buildNode(app3Service1))
					adapter.Create(buildNode(app3Service2))
开发者ID:james-masson,项目名称:loggregator,代码行数:31,代码来源:app_service_store_watcher_test.go


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