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


Golang StoreAdapter.Create方法代码示例

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


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

示例1: Announce

func Announce(localIP string, ttl time.Duration, config *config.Config, storeAdapter storeadapter.StoreAdapter, logger *gosteno.Logger) chan (chan bool) {
	dopplerMetaBytes, err := buildDopplerMeta(localIP, config)
	if err != nil {
		panic(err)
	}

	key := fmt.Sprintf("%s/%s/%s/%d", META_ROOT, config.Zone, config.JobName, config.Index)
	logger.Debugf("Starting Health Status Updates to Store: %s", key)

	node := storeadapter.StoreNode{
		Key:   key,
		Value: dopplerMetaBytes,
		TTL:   uint64(ttl.Seconds()),
	}
	// Call to create to make sure node is created before we return
	storeAdapter.Create(node)
	status, stopChan, err := storeAdapter.MaintainNode(node)

	if err != nil {
		panic(err)
	}

	// The status channel needs to be drained to maintain the node within the etcd cluster
	go func() {
		for stat := range status {
			logger.Debugf("Health updates channel pushed %v at time %v", stat, time.Now())
		}
	}()

	return stopChan
}
开发者ID:yingkitw,项目名称:loggregator,代码行数:31,代码来源:announcer.go

示例2: 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

示例3:

			finder.Stop()
		})

		getCallbackCount := func() int {
			return int(atomic.LoadInt32(callbackCount))
		}

		getPreferredCount := func() int {
			return int(atomic.LoadInt32(preferredCount))
		}

		testUpdateFinder := func(updatedAddress map[string]string) func() {
			return func() {
				Context("when a service exists", func() {
					JustBeforeEach(func() {
						err := storeAdapter.Create(node)
						Expect(err).NotTo(HaveOccurred())

						finder.Start()
						Eventually(finder.AllServers).ShouldNot(HaveLen(0))
						Expect(finder.PreferredServers()).NotTo(HaveLen(0))
					})

					It("updates the service", func() {
						err := storeAdapter.Update(updateNode)
						Expect(err).NotTo(HaveOccurred())

						Eventually(finder.AllServers).Should(Equal(updatedAddress))
						Expect(getCallbackCount()).To(Equal(2))
						Expect(finder.PreferredServers()).To(Equal(updatedAddress))
						Expect(getPreferredCount()).To(Equal(2))
开发者ID:sunatthegilddotcom,项目名称:loggregator,代码行数:31,代码来源:finder_test.go

示例4:

		})
	})

	Describe("Loading listener state on startup", func() {
		Context("when the store is empty", func() {
			It("should not send anything on the output channels", func() {
				go listener.Run()

				assertNoDataOnChannel(outAddChan)
				assertNoDataOnChannel(outRemoveChan)
			})
		})

		Context("when the store has AppServices in it", func() {
			BeforeEach(func() {
				adapter.Create(buildNode(app1Service1))
				adapter.Create(buildNode(app1Service2))
				adapter.Create(buildNode(app2Service1))
			})

			It("should send all the AppServices on the output add channel", func(done Done) {
				go listener.Run()

				appServices := drainOutgoingChannel(outAddChan, 3)

				Expect(appServices).To(ContainElement(app1Service1))
				Expect(appServices).To(ContainElement(app1Service2))
				Expect(appServices).To(ContainElement(app2Service1))

				assertNoDataOnChannel(outRemoveChan)
开发者ID:james-masson,项目名称:loggregator,代码行数:30,代码来源:app_service_store_watcher_test.go


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