当前位置: 首页>>代码示例>>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;未经允许,请勿转载。