public void ShouldNotAllowNullAction() { var builder = new StreamBuilder(); IKStream <string, string> stream = builder.Stream <string, string>("topic"); Assert.Throws <ArgumentNullException>(() => stream.Peek(null)); }
private IKStream <K, V>[] DoBranch(string named = null, params Func <K, V, bool>[] predicates) { var namedInternal = new Named(named); if (predicates.Length == 0) { throw new ArgumentException("branch() requires at least one predicate"); } String branchName = namedInternal.OrElseGenerateWithPrefix(this.builder, BRANCH_NAME); String[] childNames = new String[predicates.Length]; for (int i = 0; i < predicates.Length; i++) { childNames[i] = namedInternal.SuffixWithOrElseGet($"predicate-{i}", this.builder, BRANCHCHILD_NAME); } ProcessorParameters <K, V> processorParameters = new ProcessorParameters <K, V>(new KStreamBranch <K, V>(predicates, childNames), branchName); ProcessorGraphNode <K, V> branchNode = new ProcessorGraphNode <K, V>(branchName, processorParameters); this.builder.AddGraphNode(node, branchNode); IKStream <K, V>[] branchChildren = new IKStream <K, V> [predicates.Length]; for (int i = 0; i < predicates.Length; i++) { ProcessorParameters <K, V> innerProcessorParameters = new ProcessorParameters <K, V>(new PassThrough <K, V>(), childNames[i]); ProcessorGraphNode <K, V> branchChildNode = new ProcessorGraphNode <K, V>(childNames[i], innerProcessorParameters); builder.AddGraphNode(branchNode, branchChildNode); branchChildren[i] = new KStream <K, V>(childNames[i], this.keySerdes, this.valueSerdes, setSourceNodes, branchChildNode, builder); } return(branchChildren); }
public void GroupByKey() { var builder = new StreamBuilder(); IKStream <string, string> stream = builder.Stream <string, string>("topic"); stream.GroupByKey(); stream.GroupByKey <StringSerDes, StringSerDes>(); }
public void SouldNotAllowSelectorNullGroupBy() { var builder = new StreamBuilder(); IKStream <string, string> stream = builder.Stream <string, string>("topic"); Func <string, string, string> selector1 = null; IKeyValueMapper <string, string, string> selector2 = null; Assert.Throws <ArgumentNullException>(() => stream.GroupBy(selector1)); Assert.Throws <ArgumentNullException>(() => stream.GroupBy(selector2)); Assert.Throws <ArgumentNullException>(() => stream.GroupBy <string, StringSerDes>(selector1)); Assert.Throws <ArgumentNullException>(() => stream.GroupBy <string, StringSerDes>(selector2)); }
public void RepartitionTestJoinTopology() { var config = new StreamConfig <StringSerDes, StringSerDes> { ApplicationId = "test-repartition-processor" }; var supplier = new MockKafkaSupplier(10); StreamBuilder builder = new StreamBuilder(); IKStream <string, string> stream1 = builder .Stream <string, string>("topic") .Map((k, v) => KeyValuePair.Create(k.ToUpper(), v)); IKStream <string, string> stream2 = builder.Stream <string, string>("topic2"); stream1.Join(stream2, (v1, v2) => $"{v1}-{v2}", JoinWindowOptions.Of(TimeSpan.FromMinutes(1)), StreamJoinProps.As <string, string, string>("join-store")) .To("output"); Topology t = builder.Build(); using (var driver = new TopologyTestDriver(t.Builder, config, TopologyTestDriver.Mode.ASYNC_CLUSTER_IN_MEMORY, supplier)) { var inputTopic = driver.CreateInputTopic <string, string>("topic"); var inputTopic2 = driver.CreateInputTopic <string, string>("topic2"); var outputTopic = driver.CreateOuputTopic <string, string>("output"); inputTopic.PipeInput("test", "coucou"); inputTopic2.PipeInput("TEST", "sylvain"); inputTopic2.PipeInput("TEST2", "antoine"); inputTopic.PipeInput("test2", "test"); var records = IntegrationTestUtils .WaitUntilMinKeyValueRecordsReceived(outputTopic, 2) .ToUpdateDictionary(r => r.Message.Key, r => r.Message.Value); Assert.IsNotNull(records); Assert.AreEqual(2, records.Count); Assert.AreEqual("coucou-sylvain", records["TEST"]); Assert.AreEqual("test-antoine", records["TEST2"]); } }
static async System.Threading.Tasks.Task Main(string[] args) { var config = new StreamConfig <StringSerDes, StringSerDes>(); config.ApplicationId = "test-app"; config.BootstrapServers = "localhost:9092"; StreamBuilder builder = new StreamBuilder(); IKStream <string, string> kStream = builder.Stream <string, string>("test-topic"); kStream.Print(Printed <string, string> .ToOut()); Topology t = builder.Build(); KafkaStream stream = new KafkaStream(t, config); Console.CancelKeyPress += (o, e) => stream.Dispose(); await stream.StartAsync(); }