當前位置: 首頁>>代碼示例>>Golang>>正文


Golang storeadapter.StoreNode類代碼示例

本文整理匯總了Golang中github.com/cloudfoundry/storeadapter.StoreNode的典型用法代碼示例。如果您正苦於以下問題:Golang StoreNode類的具體用法?Golang StoreNode怎麽用?Golang StoreNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了StoreNode類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: makeStoreNode

func (adapter *ETCDStoreAdapter) makeStoreNode(etcdNode *etcd.Node) *storeadapter.StoreNode {
	if etcdNode == nil {
		return nil
	}

	if etcdNode.Dir {
		node := storeadapter.StoreNode{
			Key:        etcdNode.Key,
			Dir:        true,
			Value:      []byte{},
			ChildNodes: []storeadapter.StoreNode{},
			TTL:        uint64(etcdNode.TTL),
			Index:      uint64(etcdNode.ModifiedIndex),
		}

		for _, child := range etcdNode.Nodes {
			node.ChildNodes = append(node.ChildNodes, *adapter.makeStoreNode(child))
		}

		return &node
	} else {
		return &storeadapter.StoreNode{
			Key:   etcdNode.Key,
			Value: []byte(etcdNode.Value),
			TTL:   uint64(etcdNode.TTL),
			Index: uint64(etcdNode.ModifiedIndex),
		}
	}
}
開發者ID:idouba,項目名稱:gorouter,代碼行數:29,代碼來源:etcd_store_adapter.go

示例2: MaintainNode

func (adapter *ETCDStoreAdapter) MaintainNode(storeNode storeadapter.StoreNode) (<-chan bool, chan (chan bool), error) {
	if storeNode.TTL == 0 {
		return nil, nil, storeadapter.ErrorInvalidTTL
	}

	if len(storeNode.Value) == 0 {
		guid, err := uuid.NewV4()
		if err != nil {
			return nil, nil, err
		}

		storeNode.Value = []byte(guid.String())
	}

	releaseNode := make(chan chan bool)
	nodeStatus := make(chan bool)

	go adapter.maintainNode(storeNode, nodeStatus, releaseNode)

	return nodeStatus, releaseNode, nil
}
開發者ID:idouba,項目名稱:gorouter,代碼行數:21,代碼來源:etcd_store_adapter.go

示例3:

			})
		})

		It("Stops", func() {
			finder.Stop()
			Eventually(stopChan).Should(BeClosed())
		})
	})

	Context("with a real etcd", func() {
		var (
			storeAdapter storeadapter.StoreAdapter
			node         storeadapter.StoreNode
			updateNode   storeadapter.StoreNode

			updateCallback func(all map[string]string, preferred map[string]string)
			callbackCount  *int32

			preferredCallback func(key string) bool
			preferredCount    *int32
		)

		BeforeEach(func() {
			workPool, err := workpool.NewWorkPool(10)
			Expect(err).NotTo(HaveOccurred())
			options := &etcdstoreadapter.ETCDOptions{
				ClusterUrls: etcdRunner.NodeURLS(),
			}
			storeAdapter, err = etcdstoreadapter.New(options, workPool)
			Expect(err).NotTo(HaveOccurred())
開發者ID:sunatthegilddotcom,項目名稱:loggregator,代碼行數:30,代碼來源:finder_test.go

示例4:

			finder.Start()
		})

		It("watches and lists both roots", func() {
			Eventually(mockStoreAdapter.ListRecursivelyInput.key).Should(Receive(Equal(dopplerservice.META_ROOT)))
			Eventually(mockStoreAdapter.WatchInput.key).Should(Receive(Equal(dopplerservice.META_ROOT)))
			Eventually(mockStoreAdapter.ListRecursivelyInput.key).Should(Receive(Equal(dopplerservice.LEGACY_ROOT)))
			Eventually(mockStoreAdapter.WatchInput.key).Should(Receive(Equal(dopplerservice.LEGACY_ROOT)))
			Consistently(mockStoreAdapter.WatchCalled).Should(HaveLen(2))
		})
	})

	Describe("Next (initialization)", func() {
		var (
			metaNode   storeadapter.StoreNode
			legacyNode storeadapter.StoreNode
		)

		BeforeEach(func() {
			metaNode = storeadapter.StoreNode{}
			legacyNode = storeadapter.StoreNode{}

			close(mockStoreAdapter.WatchOutput.errors)
			close(mockStoreAdapter.WatchOutput.events)
			close(mockStoreAdapter.WatchOutput.stop)

			close(mockStoreAdapter.ListRecursivelyOutput.ret1)
		})

		JustBeforeEach(func() {
			mockStoreAdapter.ListRecursivelyOutput.ret0 <- metaNode
開發者ID:kei-yamazaki,項目名稱:loggregator,代碼行數:31,代碼來源:finder_test.go


注:本文中的github.com/cloudfoundry/storeadapter.StoreNode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。