Beispiel #1
0
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),
		}
	}
}
				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{