本文整理匯總了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{