.net7, and topic lister will also create them
All checks were successful
gitea/franz/pipeline/head This commit looks good

This commit is contained in:
Adam R Grey 2023-03-08 16:25:23 -05:00
parent 5e78f52f0d
commit e1ff1db122
8 changed files with 38 additions and 12 deletions

2
.vscode/launch.json vendored
View File

@ -10,7 +10,7 @@
"request": "launch", "request": "launch",
"preLaunchTask": "build", "preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path. // If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/franz.tests/bin/Debug/net6.0/franz.tests.dll", "program": "${workspaceFolder}/franz.tests/bin/Debug/net7.0/franz.tests.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}/franz.tests", "cwd": "${workspaceFolder}/franz.tests",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console

2
Jenkinsfile vendored
View File

@ -1,7 +1,7 @@
pipeline { pipeline {
agent any agent any
tools { tools {
dotnetsdk 'dotnet6' dotnetsdk 'dotnet7'
} }
stages { stages {
stage('build franz') { stage('build franz') {

View File

@ -9,7 +9,7 @@ namespace franz.tests
static void Main(string[] args) static void Main(string[] args)
{ {
Console.WriteLine("Hello World, I'm " + Dns.GetHostName()); Console.WriteLine("Hello World, I'm " + Dns.GetHostName());
Telefranz.Configure("tester", "alloces:9092", new System.Collections.Generic.List<string>(){"a!"}); Telefranz.Configure("tester", "alloces.lan:9092", new System.Collections.Generic.List<string>(){"a!"});
Console.WriteLine("telefranz configured"); Console.WriteLine("telefranz configured");

View File

@ -6,7 +6,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -104,6 +104,7 @@ namespace franz
{ {
config = new ConsumerConfig config = new ConsumerConfig
{ {
AllowAutoCreateTopics = true,
BootstrapServers = bootstrap_servers, BootstrapServers = bootstrap_servers,
GroupId = name, GroupId = name,
AutoOffsetReset = AutoOffsetReset.Earliest AutoOffsetReset = AutoOffsetReset.Earliest

View File

@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<PackageId>greyn.franz</PackageId> <PackageId>greyn.franz</PackageId>
<Version>2.0.1</Version> <Version>2.1.0</Version>
<Authors>Adam R Grey</Authors> <Authors>Adam R Grey</Authors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Confluent.Kafka" Version="1.9.3" /> <PackageReference Include="Confluent.Kafka" Version="2.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup> </ItemGroup>

View File

@ -1,30 +1,52 @@
using franz; using franz;
using System; using System;
using System.Threading.Tasks;
using System.Linq; using System.Linq;
using Confluent.Kafka;
using Confluent.Kafka.Admin;
namespace topiclister namespace topiclister
{ {
class Program class Program
{ {
static void Main(string[] args) static async Task Main(string[] args)
{ {
Telefranz.Configure("shut up", "localhost:9092"); try{
var ignoreme = Telefranz.Instance ;
}
catch(NotInitializedException)
{
//gulp, mmm
}
var listOfBs = AppDomain.CurrentDomain.GetAssemblies() var listOfBs = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(domainAssembly => domainAssembly.GetTypes()) .SelectMany(domainAssembly => domainAssembly.GetTypes())
.Where(type => type.IsSubclassOf(typeof(gray_messages.message)) && !type.IsAbstract) .Where(type => type.IsSubclassOf(typeof(gray_messages.message)) && !type.IsAbstract)
.ToList(); .ToList();
if (listOfBs != null && listOfBs.Any()) if (listOfBs != null && listOfBs.Any())
{
using (var adminClient = new AdminClientBuilder(new AdminClientConfig { BootstrapServers = "alloces.lan:9092" }).Build())
{ {
foreach (var b in listOfBs) foreach (var b in listOfBs)
{ {
Console.WriteLine(b); 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 else
{ {
Console.WriteLine(":("); Console.WriteLine(":(");
} }
} }
} }
} }

View File

@ -6,7 +6,10 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Confluent.Kafka" Version="2.0.2" />
</ItemGroup>
</Project> </Project>