.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",
"preLaunchTask": "build",
// 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": [],
"cwd": "${workspaceFolder}/franz.tests",
// 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 {
agent any
tools {
dotnetsdk 'dotnet6'
dotnetsdk 'dotnet7'
}
stages {
stage('build franz') {

View File

@ -9,7 +9,7 @@ namespace franz.tests
static void Main(string[] args)
{
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");

View File

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

View File

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

View File

@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<PackageId>greyn.franz</PackageId>
<Version>2.0.1</Version>
<Version>2.1.0</Version>
<Authors>Adam R Grey</Authors>
</PropertyGroup>
<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" />
</ItemGroup>

View File

@ -1,30 +1,52 @@
using franz;
using System;
using System.Threading.Tasks;
using System.Linq;
using Confluent.Kafka;
using Confluent.Kafka.Admin;
namespace topiclister
{
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()
.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);
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(":(");
}
}
}
}

View File

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