Example #1
0
        internal KStream <K, V> Stream <K, V>(string topic, ConsumedInternal <K, V> consumed)
        {
            var name = new Named(consumed.Named).OrElseGenerateWithPrefix(this, KStream.SOURCE_NAME);
            var node = new StreamSourceNode <K, V>(topic, name, consumed);

            this.AddGraphNode(root, node);
            KStream <K, V> stream = new KStream <K, V>(name, consumed.KeySerdes, consumed.ValueSerdes, new List <string> {
                name
            }, node, this);

            return(stream);
        }
        public void AppendChildTest()
        {
            RootNode root   = new RootNode();
            var      source = new StreamSourceNode <string, string>(
                "topic",
                "source-01",
                new Stream.Internal.ConsumedInternal <string, string>("source-01", new StringSerDes(), new StringSerDes(), null));

            root.AppendChild(source);

            Assert.IsFalse(root.IsEmpty);
            Assert.AreEqual(new string[] { "ROOT-NODE" }, source.ParentNodeNames());
        }
        public void ClearChildTest()
        {
            RootNode root   = new RootNode();
            var      source = new StreamSourceNode <string, string>(
                "topic",
                "source-01",
                new Stream.Internal.ConsumedInternal <string, string>("source-01", new StringSerDes(), new StringSerDes(), null));

            root.AppendChild(source);
            root.ClearChildren();

            Assert.IsTrue(root.IsEmpty);
        }
        public void WriteTopologyTest()
        {
            var builder = new InternalTopologyBuilder();
            List <StreamGraphNode> nodes = new List <StreamGraphNode>();

            RootNode root   = new RootNode();
            var      source = new StreamSourceNode <string, string>(
                "topic",
                "source-01",
                new Stream.Internal.ConsumedInternal <string, string>("source-01", new StringSerDes(),
                                                                      new StringSerDes(), null));

            root.AppendChild(source);
            nodes.Add(source);

            var filterParameters =
                new ProcessorParameters <string, string>(
                    new KStreamFilter <string, string>((k, v) => true, false), "filter-02");
            var filter = new ProcessorGraphNode <string, string>("filter-02", filterParameters);

            source.AppendChild(filter);
            nodes.Add(filter);

            var to = new StreamSinkNode <string, string>(
                new StaticTopicNameExtractor <string, string>("topic2"), "to-03",
                new Stream.Internal.Produced <string, string>(
                    new StringSerDes(),
                    new StringSerDes())
                );

            filter.AppendChild(to);
            nodes.Add(to);

            builder.BuildTopology(root, nodes);

            Assert.IsTrue(root.AllParentsWrittenToTopology);
            Assert.IsTrue(source.AllParentsWrittenToTopology);
            Assert.IsTrue(filter.AllParentsWrittenToTopology);
            Assert.IsTrue(to.AllParentsWrittenToTopology);

            var topology = builder.BuildTopology();

            Assert.IsTrue(topology.SourceOperators.ContainsKey("topic"));
            Assert.IsTrue(topology.ProcessorOperators.ContainsKey("filter-02"));
            Assert.IsTrue(topology.SinkOperators.ContainsKey("topic2"));
        }