當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。