2022-11-30 18:29:44 -05:00
|
|
|
|
using franz;
|
|
|
|
|
using System;
|
2023-03-08 16:25:23 -05:00
|
|
|
|
using System.Threading.Tasks;
|
2022-11-30 18:29:44 -05:00
|
|
|
|
using System.Linq;
|
2023-03-08 16:25:23 -05:00
|
|
|
|
using Confluent.Kafka;
|
|
|
|
|
using Confluent.Kafka.Admin;
|
2022-11-30 18:29:44 -05:00
|
|
|
|
|
|
|
|
|
namespace topiclister
|
|
|
|
|
{
|
|
|
|
|
class Program
|
|
|
|
|
{
|
2023-03-08 16:25:23 -05:00
|
|
|
|
static async Task Main(string[] args)
|
2022-11-30 18:29:44 -05:00
|
|
|
|
{
|
2023-03-08 16:25:23 -05:00
|
|
|
|
try{
|
2023-05-21 19:02:53 -04:00
|
|
|
|
var ignoreme = Telefranz.Instance ;
|
2023-03-08 16:25:23 -05:00
|
|
|
|
}
|
|
|
|
|
catch(NotInitializedException)
|
|
|
|
|
{
|
|
|
|
|
//gulp, mmm
|
|
|
|
|
}
|
2022-11-30 18:29:44 -05:00
|
|
|
|
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())
|
|
|
|
|
{
|
2023-03-08 16:25:23 -05:00
|
|
|
|
using (var adminClient = new AdminClientBuilder(new AdminClientConfig { BootstrapServers = "alloces.lan:9092" }).Build())
|
2022-11-30 18:29:44 -05:00
|
|
|
|
{
|
2023-03-08 16:25:23 -05:00
|
|
|
|
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}");
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-30 18:29:44 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(":(");
|
|
|
|
|
}
|
2023-03-08 16:25:23 -05:00
|
|
|
|
|
2022-11-30 18:29:44 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|