kafkaflow icon indicating copy to clipboard operation
kafkaflow copied to clipboard

Create Topic if not exist

Open gsferreira opened this issue 2 years ago • 2 comments

Summary

Add the option to the framework to Create a Topic if not exist when a Cluster is configured.

Background and Motivation

In scenarios like demos or coding samples, it simplifies the author's life.

Proposed Feature

                kafka => kafka
                    .UseConsoleLog()
                    .AddCluster(
                        cluster => cluster
                            .WithBrokers(new[] { "localhost:9092" })
                            .CreateTopicIfNotExists("my-topic-name", 1, 1)
                            .AddProducer(
                            ...
  • Add to the ClusterConfiguration an option CreateTopicIfNotExists(string topicName), int numberOfPartitions, int numberOfReplicas)

Open questions

  1. Where's the best place to perform the task? Should we do it on KafkaConfigurationBuilder.Build()?

gsferreira avatar Aug 03 '22 10:08 gsferreira

Where's the best place to perform the task? Should we do it on KafkaConfigurationBuilder.Build()?

Yes, I think it can be a good place.

filipeesch avatar Aug 09 '22 11:08 filipeesch

Perfect. I can peek up this one and open a PR.

gsferreira avatar Aug 09 '22 13:08 gsferreira