using franz; using System; using System.Threading.Tasks; using System.Linq; using Confluent.Kafka; using Confluent.Kafka.Admin; namespace topiclister { class Program { static async Task Main(string[] args) { try{ var ignoreme = Telefranz.Instance ; } catch(NotInitializedException) { //gulp, mmm } var listOfBs = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(domainAssembly => domainAssembly.GetTypes()) .Where(type => type.IsSubclassOf(typeof(gray_messages.message)) && !type.IsAbstract) .ToList(); if (listOfBs != null && listOfBs.Any()) { using (var adminClient = new AdminClientBuilder(new AdminClientConfig { BootstrapServers = "alloces.lan:9092" }).Build()) { foreach (var b in listOfBs) { Console.WriteLine(b.ToString()); try { await adminClient.CreateTopicsAsync(new TopicSpecification[] { new TopicSpecification { Name = b.ToString(), ReplicationFactor = 1, NumPartitions = 1, } }); } catch (CreateTopicsException e) { Console.WriteLine($"An error occured creating topic {e.Results[0].Topic}: {e.Results[0].Error.Reason}"); } } } } else { Console.WriteLine(":("); } } } }