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


Golang StoreAdapter.Get方法代码示例

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


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

示例1: AddETCDNode

func AddETCDNode(etcdAdapter storeadapter.StoreAdapter, key string, value string) {
	node := storeadapter.StoreNode{
		Key:   key,
		Value: []byte(value),
		TTL:   uint64(20),
	}
	etcdAdapter.Create(node)
	recvNode, err := etcdAdapter.Get(key)
	Expect(err).NotTo(HaveOccurred())
	Expect(string(recvNode.Value)).To(Equal(value))
}
开发者ID:rakutentech,项目名称:loggregator,代码行数:11,代码来源:helpers.go

示例2:

				{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))

			_, err = storeAdapter.Get("/hm/v16/delete/me")
			Ω(err).Should(Equal(storeadapter.ErrorKeyNotFound))
		})

		It("should leave the current version alone", func() {
			_, err := storeAdapter.Get("/hm/v17/leave/me/alone")
			Ω(err).ShouldNot(HaveOccurred())

			_, err = storeAdapter.Get("/hm/v17/leave/me/v1/alone")
			Ω(err).ShouldNot(HaveOccurred())
		})

		It("should leave newer versions alone", func() {
开发者ID:cgrotz,项目名称:hm9000,代码行数:31,代码来源:compact_test.go

示例3:

	BeforeEach(func() {
		storeAdapter = etcdstoreadapter.NewETCDStoreAdapter(etcdRunner.NodeURLS(), workerpool.NewWorkerPool(conf.StoreMaxConcurrentRequests))
		err := storeAdapter.Connect()
		Ω(err).ShouldNot(HaveOccurred())

		store = NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())
	})

	Describe("Getting and setting a metric", func() {
		BeforeEach(func() {
			err := store.SaveMetric("sprockets", 17)
			Ω(err).ShouldNot(HaveOccurred())
		})

		It("should store the metric under /metrics", func() {
			_, err := storeAdapter.Get("/hm/v1/metrics/sprockets")
			Ω(err).ShouldNot(HaveOccurred())
		})

		Context("when the metric is present", func() {
			It("should return the stored value and no error", func() {
				value, err := store.GetMetric("sprockets")
				Ω(err).ShouldNot(HaveOccurred())
				Ω(value).Should(BeNumerically("==", 17))
			})

			Context("and it is overwritten", func() {
				BeforeEach(func() {
					err := store.SaveMetric("sprockets", 23.5)
					Ω(err).ShouldNot(HaveOccurred())
				})
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:31,代码来源:metrics_test.go

示例4: buildComponent

var _ = BeforeEach(func() {
	const (
		BLUE       = 34
		PURPLE     = 35
		LIGHT_BLUE = 36
	)

	dopplerSession = startComponent(dopplerExecutablePath, "doppler", PURPLE, "--config=fixtures/doppler.json")
	var err error
	LocalIPAddress, err = localip.LocalIP()
	Expect(err).ToNot(HaveOccurred())

	// Wait for doppler to startup
	Eventually(func() error {
		_, err := etcdAdapter.Get("healthstatus/doppler/z1/doppler_z1/0")
		return err
	}, 11).Should(BeNil())

	metronSession = startComponent(metronExecutablePath, "metron", BLUE, "--config=fixtures/metron.json")

	tcSession = startComponent(trafficControllerExecutablePath, "tc", LIGHT_BLUE, "--config=fixtures/trafficcontroller.json", "--disableAccessControl")

	// Wait for traffic controller to startup
	waitOnURL("http://" + LocalIPAddress + ":49630")

	// Metron will report that it is up when it really isn't (at least according to the /varz endpoint)
	time.Sleep(200 * time.Millisecond)
})

func buildComponent(componentName string) (pathToComponent string) {
开发者ID:Jonty,项目名称:loggregator,代码行数:30,代码来源:integration_test_suite_test.go

示例5:

					dopplerservice.Announce(localIP, time.Second, &conf, fakeadapter, loggertesthelper.Logger())
				}).To(Panic())
			})

			Context("when tls transport is enabled", func() {
				It("announces udp, tcp, and tls values", func() {
					dopplerMeta := fmt.Sprintf(`{"version": 1, "endpoints":["udp://%[1]s:1234", "tcp://%[1]s:5678", "ws://%[1]s:8888", "tls://%[1]s:9012"]}`, localIP)

					conf.EnableTLSTransport = true
					conf.TLSListenerConfig = config.TLSListenerConfig{
						Port: 9012,
					}
					stopChan = dopplerservice.Announce(localIP, time.Second, &conf, etcdAdapter, loggertesthelper.Logger())

					Eventually(func() []byte {
						node, err := etcdAdapter.Get(dopplerKey)
						if err != nil {
							return nil
						}
						return node.Value
					}).Should(MatchJSON(dopplerMeta))
				})
			})

			Context("when tls transport is disabled", func() {
				It("announces only udp and tcp values", func() {
					dopplerMeta := fmt.Sprintf(`{"version": 1, "endpoints":["udp://%[1]s:1234", "tcp://%[1]s:5678", "ws://%[1]s:8888" ]}`, localIP)

					conf.EnableTLSTransport = false
					stopChan = dopplerservice.Announce(localIP, time.Second, &conf, etcdAdapter, loggertesthelper.Logger())
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:30,代码来源:announcer_test.go

示例6:

		Ω(err).ShouldNot(HaveOccurred())

		store = NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())
	})

	Describe("Bumping freshness", func() {
		bumpingFreshness := func(key string, ttl uint64, bump func(store Store, timestamp time.Time) error) {
			var timestamp time.Time

			BeforeEach(func() {
				timestamp = time.Now()
			})

			Context("when the key is missing", func() {
				BeforeEach(func() {
					_, err := storeAdapter.Get(key)
					Ω(err).Should(Equal(storeadapter.ErrorKeyNotFound))

					err = bump(store, timestamp)
					Ω(err).ShouldNot(HaveOccurred())
				})

				It("should create the key with the current timestamp and a TTL", func() {
					value, err := storeAdapter.Get(key)

					Ω(err).ShouldNot(HaveOccurred())

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

					Ω(freshnessTimestamp.Timestamp).Should(Equal(timestamp.Unix()))
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:31,代码来源:freshness_test.go

示例7:

	"loggregator/domain"
)

var _ = Describe("AppServiceStore", func() {
	var store *AppServiceStore
	var adapter storeadapter.StoreAdapter
	var incomingChan chan domain.AppServices

	var app1Service1 domain.AppService
	var app1Service2 domain.AppService
	var app2Service1 domain.AppService

	assertInStore := func(appServices ...domain.AppService) {
		for _, appService := range appServices {
			Eventually(func() error {
				_, err := adapter.Get(path.Join("/loggregator/services/", appService.AppId, appService.Id()))
				return err
			}).ShouldNot(HaveOccurred())
		}
	}

	assertNotInStore := func(appServices ...domain.AppService) {
		for _, appService := range appServices {
			Eventually(func() error {
				_, err := adapter.Get(path.Join("/loggregator/services/", appService.AppId, appService.Id()))
				return err
			}).Should(Equal(storeadapter.ErrorKeyNotFound))
		}
	}

	assertAppNotInStore := func(appIds ...string) {
开发者ID:nkuacac,项目名称:loggregator,代码行数:31,代码来源:app_service_store_test.go

示例8:

			drainOutgoingChannel(outAddChan, 3)
		})

		It("does not send updates when the data has already been processed", func() {
			adapter.Create(buildNode(app1Service1))
			adapter.Create(buildNode(app1Service2))

			Expect(outAddChan).To(BeEmpty())
			Expect(outRemoveChan).To(BeEmpty())
		})

		Context("when there is new data in the store", func() {
			Context("when an existing app has a new service through a create operation", func() {
				It("adds that service to the outgoing add channel", func() {
					app2Service2 := appservice.AppService{AppId: APP2_ID, Url: "syslog://new.example.com:12345"}
					_, err := adapter.Get(key(app2Service2))
					Expect(err).To(Equal(storeadapter.ErrorKeyNotFound))

					adapter.Create(buildNode(app2Service2))

					var appService appservice.AppService
					Eventually(outAddChan).Should(Receive(&appService))
					Expect(appService).To(Equal(app2Service2))

					Expect(outRemoveChan).To(BeEmpty())
				})
			})

			Context("When an existing app gets a new service through an update operation", func() {
				It("adds that service to the outgoing add channel", func() {
					app2Service2 := appservice.AppService{AppId: APP2_ID, Url: "syslog://new.example.com:12345"}
开发者ID:pkdevbox,项目名称:loggregatorlib,代码行数:31,代码来源:app_service_store_watcher_test.go

示例9:

					Ω(results).Should(HaveLen(3))
					Ω(results).Should(ContainElement(otherDea.GetApp(0).InstanceAtIndex(1).Heartbeat()))
					Ω(results).Should(ContainElement(otherDea.GetApp(1).InstanceAtIndex(0).Heartbeat()))
					Ω(results).Should(ContainElement(heartbeatOnOtherDea))

					//we fetch twice to ensure that nothing is incorrectly deleted
					results, err = store.GetInstanceHeartbeats()
					Ω(err).ShouldNot(HaveOccurred())
					Ω(results).Should(HaveLen(3))
					Ω(results).Should(ContainElement(otherDea.GetApp(0).InstanceAtIndex(1).Heartbeat()))
					Ω(results).Should(ContainElement(otherDea.GetApp(1).InstanceAtIndex(0).Heartbeat()))
					Ω(results).Should(ContainElement(heartbeatOnOtherDea))
				})

				It("should remove expired instance heartbeats from the store", func() {
					_, err := storeAdapter.Get("/hm/v1/apps/actual/" + store.AppKey(dea.GetApp(0).AppGuid, dea.GetApp(0).AppVersion) + "/" + dea.GetApp(0).InstanceAtIndex(1).Heartbeat().StoreKey())
					Ω(err).ShouldNot(HaveOccurred())
					_, err = storeAdapter.Get("/hm/v1/apps/actual/" + store.AppKey(dea.GetApp(1).AppGuid, dea.GetApp(1).AppVersion) + "/" + dea.GetApp(1).InstanceAtIndex(3).Heartbeat().StoreKey())
					Ω(err).ShouldNot(HaveOccurred())

					_, err = store.GetInstanceHeartbeats()
					Ω(err).ShouldNot(HaveOccurred())

					_, err = storeAdapter.Get("/hm/v1/apps/actual/" + store.AppKey(dea.GetApp(0).AppGuid, dea.GetApp(0).AppVersion) + "/" + dea.GetApp(0).InstanceAtIndex(1).Heartbeat().StoreKey())
					Ω(err).Should(Equal(storeadapter.ErrorKeyNotFound))
					_, err = storeAdapter.Get("/hm/v1/apps/actual/" + store.AppKey(dea.GetApp(1).AppGuid, dea.GetApp(1).AppVersion) + "/" + dea.GetApp(1).InstanceAtIndex(3).Heartbeat().StoreKey())
					Ω(err).Should(Equal(storeadapter.ErrorKeyNotFound))
				})

				Context("if it fails to remove them", func() {
					It("should soldier on", func() {
开发者ID:cgrotz,项目名称:hm9000,代码行数:31,代码来源:actual_state_test.go

示例10:

	Eventually(metronSession.Buffer).Should(gbytes.Say("metron started"))

	dopplerSession = startComponent(
		dopplerExecutablePath,
		"doppler",
		PURPLE,
		"--config=fixtures/"+dopplerConfig+".json",
	)
	var err error
	LocalIPAddress, err = localip.LocalIP()
	Expect(err).ToNot(HaveOccurred())

	// wait for doppler to register
	key := fmt.Sprintf("%s/z1/doppler_z1/0", dopplerservice.LEGACY_ROOT)
	Eventually(func() bool {
		_, err := etcdAdapter.Get(key)
		return err == nil
	}, 5).Should(BeTrue())

	key = fmt.Sprintf("%s/z1/doppler_z1/0", dopplerservice.META_ROOT)
	Eventually(func() bool {
		_, err := etcdAdapter.Get(key)
		return err == nil
	}, 1).Should(BeTrue())

	tcSession = startComponent(
		trafficControllerExecutablePath,
		"tc",
		LIGHT_BLUE,
		"--config=fixtures/trafficcontroller.json",
		"--disableAccessControl",
开发者ID:yingkitw,项目名称:loggregator,代码行数:31,代码来源:integration_test_suite_test.go

示例11:

	})

	AfterEach(func() {
		storeAdapter.Disconnect()
	})

	Describe("Saving crash state", func() {
		BeforeEach(func() {
			err := store.SaveCrashCounts(crashCount1, crashCount2)
			Ω(err).ShouldNot(HaveOccurred())
		})

		It("stores the passed in crash state", func() {
			expectedTTL := uint64(conf.MaximumBackoffDelay().Seconds()) * 2

			node, err := storeAdapter.Get("/hm/v1/apps/crashes/" + crashCount1.AppGuid + "," + crashCount1.AppVersion + "/1")
			Ω(err).ShouldNot(HaveOccurred())
			Ω(node).Should(Equal(storeadapter.StoreNode{
				Key:   "/hm/v1/apps/crashes/" + crashCount1.AppGuid + "," + crashCount1.AppVersion + "/1",
				Value: crashCount1.ToJSON(),
				TTL:   expectedTTL,
			}))

			node, err = storeAdapter.Get("/hm/v1/apps/crashes/" + crashCount2.AppGuid + "," + crashCount2.AppVersion + "/4")
			Ω(err).ShouldNot(HaveOccurred())
			Ω(node).Should(Equal(storeadapter.StoreNode{
				Key:   "/hm/v1/apps/crashes/" + crashCount2.AppGuid + "," + crashCount2.AppVersion + "/4",
				Value: crashCount2.ToJSON(),
				TTL:   expectedTTL,
			}))
		})
开发者ID:karlpilkington,项目名称:golang-devops-stuff,代码行数:31,代码来源:crash_count_test.go


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