本文整理汇总了Golang中github.com/cloudfoundry/storeadapter.StoreNode.ChildNodes方法的典型用法代码示例。如果您正苦于以下问题:Golang StoreNode.ChildNodes方法的具体用法?Golang StoreNode.ChildNodes怎么用?Golang StoreNode.ChildNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/storeadapter.StoreNode
的用法示例。
在下文中一共展示了StoreNode.ChildNodes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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),
}
}
}
示例2:
expected := dopplerservice.Event{
UDPDopplers: []string{"1.2.3.4:567"},
TLSDopplers: []string{"9.8.7.6:555"},
}
Expect(finder.Next()).To(Equal(expected))
})
})
Context("with invalid JSON", func() {
BeforeEach(func() {
protocols = []string{"udp"}
metaNode, legacyNode = etcdNodes(map[string][]string{
"z1/doppler_z1/0": []string{"udp://1.2.3.4:567"},
}, nil)
metaNode.ChildNodes = append(metaNode.ChildNodes, storeadapter.StoreNode{
Key: path.Join(dopplerservice.META_ROOT, "z1/doppler_z1/0"),
Value: []byte(`gobbledegook`),
})
})
It("ignores the doppler", func() {
expected := dopplerservice.Event{
UDPDopplers: []string{"1.2.3.4:567"},
}
Expect(finder.Next()).To(Equal(expected))
})
})
Context("with data in the meta node", func() {
BeforeEach(func() {
protocols = []string{"tls", "udp", "ws"}
metaNode, legacyNode = etcdNodes(map[string][]string{